]> git.mxchange.org Git - flightgear.git/commitdiff
Reset: guard against NULL HUD / lighting
authorJames Turner <zakalawe@mac.com>
Tue, 5 Nov 2013 05:32:43 +0000 (05:32 +0000)
committerJames Turner <zakalawe@mac.com>
Tue, 12 Nov 2013 22:51:10 +0000 (22:51 +0000)
src/Viewer/renderer.cxx

index 2859e17deff2dc5d398193184795e1c86338aaf3..465748624f02a4a5b3a018413559005af81182ae 100644 (file)
@@ -221,9 +221,12 @@ public:
     glPushAttrib(GL_ALL_ATTRIB_BITS);
     glPushClientAttrib(~0u);
       
-    HUD *hud = static_cast<HUD*>(globals->get_subsystem("hud"));
-    hud->draw(state);
-
+    // HUD can be NULL
+      HUD *hud = static_cast<HUD*>(globals->get_subsystem("hud"));
+      if (hud) {
+          hud->draw(state);
+      }
+      
     glPopClientAttrib();
     glPopAttrib();
   }
@@ -255,6 +258,11 @@ public:
     osg::Light* light = lightSource->getLight();
     
     FGLight *l = static_cast<FGLight*>(globals->get_subsystem("lighting"));
+      if (!l) {
+          // lighting is down during re-init
+          return;
+      }
+      
     if (_isSun) {
       light->setAmbient(Vec4(0.0f, 0.0f, 0.0f, 0.0f));
       light->setDiffuse(Vec4(1.0f, 1.0f, 1.0f, 1.0f));
@@ -492,7 +500,8 @@ public:
 void
 FGRenderer::init( void )
 {
-    eventHandler = new FGEventHandler();
+    if (!eventHandler)
+        eventHandler = new FGEventHandler();
 
     sgUserDataInit( globals->get_props() );