From 2322fca9c9ffe86197e89b62cceee184df416f3b Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 5 Nov 2013 05:32:43 +0000 Subject: [PATCH] Reset: guard against NULL HUD / lighting --- src/Viewer/renderer.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Viewer/renderer.cxx b/src/Viewer/renderer.cxx index 2859e17de..465748624 100644 --- a/src/Viewer/renderer.cxx +++ b/src/Viewer/renderer.cxx @@ -221,9 +221,12 @@ public: glPushAttrib(GL_ALL_ATTRIB_BITS); glPushClientAttrib(~0u); - HUD *hud = static_cast(globals->get_subsystem("hud")); - hud->draw(state); - + // HUD can be NULL + HUD *hud = static_cast(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(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() ); -- 2.39.5