From 73163604219792ef946dba7c121e48c42391a789 Mon Sep 17 00:00:00 2001
From: James Turner <zakalawe@mac.com>
Date: Sun, 12 Jan 2014 17:18:35 +0000
Subject: [PATCH] Clear the custom OSG notify logger on shutdown.

Should avert crashes due to order of static destruction.
---
 src/Viewer/fg_os_osgviewer.cxx | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/Viewer/fg_os_osgviewer.cxx b/src/Viewer/fg_os_osgviewer.cxx
index 72481bc89..7ba993218 100644
--- a/src/Viewer/fg_os_osgviewer.cxx
+++ b/src/Viewer/fg_os_osgviewer.cxx
@@ -315,6 +315,11 @@ void fgOSExit(int code)
     viewer->setDone(true);
     viewer->getDatabasePager()->cancel();
     status = code;
+    
+    // otherwise we crash if OSG does logging during static destruction, eg
+    // GraphicsWindowX11, since OSG statics may have been created before the
+    // sglog static, despite our best efforts in boostrap.cxx
+    osg::setNotifyHandler(new osg::StandardNotifyHandler);
 }
 
 int fgOSMainLoop()