]> git.mxchange.org Git - flightgear.git/commitdiff
#738: crash when switching 2D panels
authorThorstenB <brehmt@gmail.com>
Wed, 11 Apr 2012 22:03:16 +0000 (00:03 +0200)
committerThorstenB <brehmt@gmail.com>
Wed, 11 Apr 2012 22:03:16 +0000 (00:03 +0200)
FGPanelNode doesn't always own its "_panel" object - so it's not ok to
always delete it. Use ref-counting/smart-pointers instead.

src/Main/fg_commands.cxx
src/Main/globals.cxx
src/Main/globals.hxx
src/Model/panelnode.cxx
src/Model/panelnode.hxx

index 0e158d599263e1fe18544658c7829e3c9fe41542..bf7bbdedeedf502217e85d3c39855f4062be7c77 100644 (file)
@@ -414,7 +414,6 @@ do_panel_load (const SGPropertyNode * arg)
   }
   SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
   globals->get_current_panel()->unbind();
-  delete globals->get_current_panel();
   globals->set_current_panel( new_panel );
   globals->get_current_panel()->bind();
   return true;
index 3f624f6bbfff9b4a7b057eba8c8166fa9b76dcf7..25eb5194b97248037d490fb31fc9046d3ef2b37d 100644 (file)
@@ -188,7 +188,7 @@ FGGlobals::~FGGlobals()
     delete mag;
     delete matlib;
     delete route_mgr;
-    delete current_panel;
+    current_panel = NULL;
 
     delete ATC_mgr;
 
index 01f7281070dd925be8370500c4a5ff9e7b7c61d6..9be19ff66d5157e20ea67959ff066786a129a627 100644 (file)
@@ -119,7 +119,7 @@ private:
     FGRouteMgr *route_mgr;
 
     // 2D panel
-    FGPanel *current_panel;
+    SGSharedPtr<FGPanel> current_panel;
 
     // ATC manager
     FGATCMgr *ATC_mgr;
index 2c68f95c2fc4dafff05f589a0dc91fc0dcd2b398..6657d2f7513f4dfaaf412dbb5bd9644aac9c8047 100644 (file)
@@ -153,7 +153,6 @@ void FGPanelNode::initWithPanel()
 
 FGPanelNode::~FGPanelNode()
 {
-    delete _panel;
 }
 
 osg::Matrix FGPanelNode::transformMatrix() const
index 2551495f864c654a6f04234c59afe8e405ccbd3c..2ea9c0382ac0dc22a23a6152a9a5753e09faa5d5 100644 (file)
@@ -4,6 +4,7 @@
 #include <osg/Vec3>
 #include <osg/Matrix>
 #include <osg/Drawable>
+#include <simgear/structure/SGSharedPtr.hxx>
 
 class FGPanel;
 class SGPropertyNode;
@@ -43,7 +44,7 @@ public:
 private:
     void initWithPanel();
     
-    FGPanel* _panel;
+    SGSharedPtr<FGPanel> _panel;
   
     bool _resizeToViewport;