Hi all,

for fg osg with osgviewer enabled and a camera configured in preferences.xml 
that can't be opened, fg coredumps.

This is due to using the GraphicsContext for the camera without checking if it 
has been created:

        osg::GraphicsContext* gc;
        gc = osg::GraphicsContext::createGraphicsContext(cameraTraits.get());
        gc->realize();

Attached is a patch (against current cvs) to fix this. 

Please consider applying this patch, it works perfectly for me.

Greetings, Torsten
Index: fg_os_osgviewer.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_os_osgviewer.cxx,v
retrieving revision 1.16
diff -u -p -r1.16 fg_os_osgviewer.cxx
--- fg_os_osgviewer.cxx	22 Mar 2008 09:31:08 -0000	1.16
+++ fg_os_osgviewer.cxx	17 Apr 2008 07:21:39 -0000
@@ -172,7 +172,6 @@ void fgOSOpenWindow(int w, int h, int bp
         if (strcmp(cameraNode->getName(), "camera") != 0)
           continue;
 
-	nCameras++;
         // get a new copy of the traits struct
         osg::ref_ptr<osg::GraphicsContext::Traits> cameraTraits;
         cameraTraits = new osg::GraphicsContext::Traits(*traits);
@@ -209,14 +208,17 @@ void fgOSOpenWindow(int w, int h, int bp
 
         osg::GraphicsContext* gc;
         gc = osg::GraphicsContext::createGraphicsContext(cameraTraits.get());
-        gc->realize();
-        camera->setGraphicsContext(gc);
-        // If a viewport isn't set on the camera, then it's hard to dig it
-        // out of the SceneView objects in the viewer, and the coordinates
-        // of mouse events are somewhat bizzare.
-        camera->setViewport(new osg::Viewport(0, 0, cameraTraits->width, cameraTraits->height));
-        camera->setProjectionResizePolicy(rsp);
-        viewer->addSlave(camera.get(), osg::Matrix::translate(-shearx, -sheary, 0), osg::Matrix());
+        if( gc != NULL ) {
+          gc->realize();
+          camera->setGraphicsContext(gc);
+          // If a viewport isn't set on the camera, then it's hard to dig it
+          // out of the SceneView objects in the viewer, and the coordinates
+          // of mouse events are somewhat bizzare.
+          camera->setViewport(new osg::Viewport(0, 0, cameraTraits->width, cameraTraits->height));
+          camera->setProjectionResizePolicy(rsp);
+          viewer->addSlave(camera.get(), osg::Matrix::translate(-shearx, -sheary, 0), osg::Matrix());
+          nCameras++;
+        }
       }
       if (nCameras > 1)
 	manipulator->setResizable(false);
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to