Don't crash if WindowBuild fails.
This commit is contained in:
parent
2302f04095
commit
0b3829810f
2 changed files with 11 additions and 8 deletions
|
@ -646,15 +646,16 @@ CameraInfo* CameraGroup::buildGUICamera(SGPropertyNode* cameraNode,
|
|||
const SGPropertyNode* windowNode = (cameraNode
|
||||
? cameraNode->getNode("window")
|
||||
: 0);
|
||||
if (!window) {
|
||||
if (windowNode) {
|
||||
// New style window declaration / definition
|
||||
window = wBuild->buildWindow(windowNode);
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if (!window && windowNode) {
|
||||
// New style window declaration / definition
|
||||
window = wBuild->buildWindow(windowNode);
|
||||
}
|
||||
|
||||
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->setAllowEventFocus(false);
|
||||
camera->setGraphicsContext(window->gc.get());
|
||||
|
|
|
@ -224,12 +224,14 @@ GraphicsWindow* WindowBuilder::getDefaultWindow()
|
|||
GraphicsContext::Traits* traits
|
||||
= new GraphicsContext::Traits(*defaultTraits);
|
||||
traits->windowName = "FlightGear";
|
||||
|
||||
GraphicsContext* gc = GraphicsContext::createGraphicsContext(traits);
|
||||
if (gc) {
|
||||
defaultWindow = WindowSystemAdapter::getWSA()
|
||||
->registerWindow(gc, defaultWindowName);
|
||||
return defaultWindow;
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_ALERT, "getDefaultWindow: failed to create GraphicsContext");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue