]> git.mxchange.org Git - flightgear.git/commitdiff
Canvas: Now only one global SystemAdapter is used...
authorThomas Geymayer <tomgey@gmail.com>
Mon, 9 Dec 2013 22:13:45 +0000 (23:13 +0100)
committerThomas Geymayer <tomgey@gmail.com>
Mon, 9 Dec 2013 22:13:45 +0000 (23:13 +0100)
src/Canvas/FGCanvasSystemAdapter.cxx
src/Canvas/canvas_mgr.cxx
src/Cockpit/od_gauge.cxx
src/Main/fg_init.cxx

index 0471118dd13ce516088411fa30135f134920ac62..ad774fd438c11bbaa822ff8203c802f7b840b0b4 100644 (file)
@@ -71,7 +71,8 @@ namespace canvas
   //----------------------------------------------------------------------------
   void FGCanvasSystemAdapter::removeCamera(osg::Camera* camera) const
   {
-    globals->get_renderer()->removeCamera(camera);
+    if( globals->get_renderer() )
+      globals->get_renderer()->removeCamera(camera);
   }
 
   //----------------------------------------------------------------------------
index 6bef1f476d083f021aae193a63f4d22038804f64..27c4290b62b7efdf1aa59783f2cd7fc0d4b86a33 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "canvas_mgr.hxx"
 
-#include <Canvas/FGCanvasSystemAdapter.hxx>
 #include <Cockpit/od_gauge.hxx>
 #include <Main/fg_props.hxx>
 #include <Scripting/NasalModelData.hxx>
@@ -57,11 +56,7 @@ static sc::Placements addSceneObjectPlacement( SGPropertyNode* placement,
 
 //------------------------------------------------------------------------------
 CanvasMgr::CanvasMgr():
-  simgear::canvas::CanvasMgr
-  (
-   fgGetNode("/canvas/by-index", true),
-   sc::SystemAdapterPtr( new canvas::FGCanvasSystemAdapter )
-  ),
+  simgear::canvas::CanvasMgr( fgGetNode("/canvas/by-index", true) ),
   _cb_model_reinit
   (
     this,
index 5cae2fb8e1cb13d53b412c419173d3855d6c77c6..883a17178036aabfa0a814506dca636056fd7cb2 100644 (file)
 #include <simgear/scene/material/EffectGeode.hxx>
 #include <simgear/scene/util/RenderConstants.hxx>
 
-#include <Canvas/FGCanvasSystemAdapter.hxx>
 #include <Main/globals.hxx>
 #include <Scenery/scenery.hxx>
 #include "od_gauge.hxx"
 
 #include <cassert>
 
-static simgear::canvas::SystemAdapterPtr system_adapter(
-  new canvas::FGCanvasSystemAdapter
-);
-
 //------------------------------------------------------------------------------
 FGODGauge::FGODGauge()
 {
-  setSystemAdapter(system_adapter);
+
 }
 
 //------------------------------------------------------------------------------
index e33c1aebdcbf8780e092967b80ff2459c0b0c626..0278fe03f62f08f6860512afd100f3f4ff8e297f 100644 (file)
@@ -50,6 +50,7 @@
 
 #include <osgViewer/Viewer>
 
+#include <simgear/canvas/Canvas.hxx>
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/exception.hxx>
@@ -88,6 +89,7 @@
 
 #include <Canvas/canvas_mgr.hxx>
 #include <Canvas/gui_mgr.hxx>
+#include <Canvas/FGCanvasSystemAdapter.hxx>
 #include <GUI/new_gui.hxx>
 #include <GUI/MessageBox.hxx>
 #include <Input/input.hxx>
@@ -693,6 +695,9 @@ void fgCreateSubsystems(bool duringReset) {
     ////////////////////////////////////////////////////////////////////
     // Initialize the canvas 2d drawing subsystem.
     ////////////////////////////////////////////////////////////////////
+    simgear::canvas::Canvas::setSystemAdapter(
+      simgear::canvas::SystemAdapterPtr(new canvas::FGCanvasSystemAdapter)
+    );
     globals->add_subsystem("Canvas", new CanvasMgr, SGSubsystemMgr::DISPLAY);
     globals->add_subsystem("CanvasGUI", new GUIMgr, SGSubsystemMgr::DISPLAY);