1
0
Fork 0

Don't crash if WindowBuild fails.

This commit is contained in:
James Turner 2010-12-11 14:29:05 +00:00
parent 2302f04095
commit 0b3829810f
2 changed files with 11 additions and 8 deletions

View file

@ -646,15 +646,16 @@ CameraInfo* CameraGroup::buildGUICamera(SGPropertyNode* cameraNode,
const SGPropertyNode* windowNode = (cameraNode const SGPropertyNode* windowNode = (cameraNode
? cameraNode->getNode("window") ? cameraNode->getNode("window")
: 0); : 0);
if (!window) { if (!window && windowNode) {
if (windowNode) { // New style window declaration / definition
// New style window declaration / definition window = wBuild->buildWindow(windowNode);
window = wBuild->buildWindow(windowNode);
} else {
return 0;
}
} }
if (!window) { // buildWindow can fail
SG_LOG(SG_GENERAL, SG_WARN, "CameraGroup::buildGUICamera: failed to build a window");
return NULL;
}
Camera* camera = new Camera; Camera* camera = new Camera;
camera->setAllowEventFocus(false); camera->setAllowEventFocus(false);
camera->setGraphicsContext(window->gc.get()); camera->setGraphicsContext(window->gc.get());

View file

@ -224,12 +224,14 @@ GraphicsWindow* WindowBuilder::getDefaultWindow()
GraphicsContext::Traits* traits GraphicsContext::Traits* traits
= new GraphicsContext::Traits(*defaultTraits); = new GraphicsContext::Traits(*defaultTraits);
traits->windowName = "FlightGear"; traits->windowName = "FlightGear";
GraphicsContext* gc = GraphicsContext::createGraphicsContext(traits); GraphicsContext* gc = GraphicsContext::createGraphicsContext(traits);
if (gc) { if (gc) {
defaultWindow = WindowSystemAdapter::getWSA() defaultWindow = WindowSystemAdapter::getWSA()
->registerWindow(gc, defaultWindowName); ->registerWindow(gc, defaultWindowName);
return defaultWindow; return defaultWindow;
} else { } else {
SG_LOG(SG_GENERAL, SG_ALERT, "getDefaultWindow: failed to create GraphicsContext");
return 0; return 0;
} }
} }