Commit f68447f5 authored by cornimueller's avatar cornimueller
Browse files

[FIX] Fixed seg fault when closing a WGEViewer: WPickHandler derives from an...

[FIX] Fixed seg fault when closing a WGEViewer: WPickHandler derives from an osg class and should therefore use osg::ref_ptr instead of boost::smart_ptr.
parent 6a75635e
......@@ -70,8 +70,8 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<WindowData> wdata, int x, i
m_View->setLightingMode( osg::View::HEADLIGHT ); // this is the default anyway
m_pickHandler = boost::shared_ptr< WPickHandler >( new WPickHandler() );
m_View->addEventHandler( osg::ref_ptr< WPickHandler >( m_pickHandler.get() ) );
m_pickHandler = new WPickHandler();
m_View->addEventHandler( m_pickHandler );
}
catch( ... )
{
......@@ -151,7 +151,7 @@ std::string WGEViewer::getName() const
return m_name;
}
boost::shared_ptr< WPickHandler > WGEViewer::getPickHandler()
osg::ref_ptr< WPickHandler > WGEViewer::getPickHandler()
{
return m_pickHandler;
}
......@@ -160,7 +160,7 @@ public:
*
* \return the pick handler
*/
boost::shared_ptr< WPickHandler > getPickHandler();
osg::ref_ptr< WPickHandler > getPickHandler();
protected:
......@@ -182,7 +182,7 @@ protected:
/**
* Pointer to the pick handler of the viewer.
*/
boost::shared_ptr<WPickHandler> m_pickHandler;
osg::ref_ptr<WPickHandler> m_pickHandler;
private:
};
......
......@@ -54,11 +54,6 @@
class WPickHandler: public osgGA::GUIEventHandler
{
public:
/**
* Virtual destructor needed because of virtual fuction.
*/
virtual ~WPickHandler();
/**
* Deals with the events found by the osg.
*/
......@@ -90,6 +85,17 @@ public:
boost::signals2::signal1< void, std::string >* getPickSignal();
protected:
/**
* Virtual destructor needed because of virtual function.
*
* This desctructor is protected to avoid accidentally deleting
* a instance of WPickHandler.
* This follows the philosophy of OSG to avoid problems in multithreaded
* environments, since these pointers are used deep in the OSG where
* an deletion could cause a segfault.
*/
virtual ~WPickHandler();
std::string m_hitResult; //!< Textual representation of the result of a pick.
wmath::WPosition m_hitPosGlobal; //!< Global coordinates of the first hit of the pick.
......
......@@ -125,7 +125,7 @@ private:
wmath::WPosition m_minPos; //!< The minimum position of the box
wmath::WPosition m_maxPos; //!< The maximum position of the box
boost::shared_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
osg::ref_ptr< WPickHandler > m_pickHandler; //!< A pointer to the pick handler used to get gui events for moving the box.
};
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment