1
0
Fork 0

#738: crash when switching 2D panels

FGPanelNode doesn't always own its "_panel" object - so it's not ok to
always delete it. Use ref-counting/smart-pointers instead.
This commit is contained in:
ThorstenB 2012-04-12 00:03:16 +02:00
parent 2ce5b5276f
commit 4348f17b8c
5 changed files with 4 additions and 5 deletions

View file

@ -414,7 +414,6 @@ do_panel_load (const SGPropertyNode * arg)
} }
SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path); SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
globals->get_current_panel()->unbind(); globals->get_current_panel()->unbind();
delete globals->get_current_panel();
globals->set_current_panel( new_panel ); globals->set_current_panel( new_panel );
globals->get_current_panel()->bind(); globals->get_current_panel()->bind();
return true; return true;

View file

@ -188,7 +188,7 @@ FGGlobals::~FGGlobals()
delete mag; delete mag;
delete matlib; delete matlib;
delete route_mgr; delete route_mgr;
delete current_panel; current_panel = NULL;
delete ATC_mgr; delete ATC_mgr;

View file

@ -119,7 +119,7 @@ private:
FGRouteMgr *route_mgr; FGRouteMgr *route_mgr;
// 2D panel // 2D panel
FGPanel *current_panel; SGSharedPtr<FGPanel> current_panel;
// ATC manager // ATC manager
FGATCMgr *ATC_mgr; FGATCMgr *ATC_mgr;

View file

@ -153,7 +153,6 @@ void FGPanelNode::initWithPanel()
FGPanelNode::~FGPanelNode() FGPanelNode::~FGPanelNode()
{ {
delete _panel;
} }
osg::Matrix FGPanelNode::transformMatrix() const osg::Matrix FGPanelNode::transformMatrix() const

View file

@ -4,6 +4,7 @@
#include <osg/Vec3> #include <osg/Vec3>
#include <osg/Matrix> #include <osg/Matrix>
#include <osg/Drawable> #include <osg/Drawable>
#include <simgear/structure/SGSharedPtr.hxx>
class FGPanel; class FGPanel;
class SGPropertyNode; class SGPropertyNode;
@ -43,7 +44,7 @@ public:
private: private:
void initWithPanel(); void initWithPanel();
FGPanel* _panel; SGSharedPtr<FGPanel> _panel;
bool _resizeToViewport; bool _resizeToViewport;