Canvas: Do not hold a reference to the GUI camera
It might be not be valid anymore after a reset. Just query it when needed.
This commit is contained in:
parent
f1a44c98df
commit
08aed1ccc8
2 changed files with 14 additions and 23 deletions
|
@ -97,10 +97,6 @@ CanvasMgr::CanvasMgr():
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void CanvasMgr::init()
|
void CanvasMgr::init()
|
||||||
{
|
{
|
||||||
flightgear::CameraGroup* camera_group = flightgear::CameraGroup::getDefault();
|
|
||||||
if (camera_group) {
|
|
||||||
_gui_camera = flightgear::getGUICamera(camera_group);
|
|
||||||
if (_gui_camera.valid()) {
|
|
||||||
// add our two placement factories
|
// add our two placement factories
|
||||||
sc::Canvas::addPlacementFactory
|
sc::Canvas::addPlacementFactory
|
||||||
(
|
(
|
||||||
|
@ -110,11 +106,9 @@ void CanvasMgr::init()
|
||||||
canvas->getCullCallback(),
|
canvas->getCullCallback(),
|
||||||
canvas);
|
canvas);
|
||||||
});
|
});
|
||||||
|
|
||||||
sc::Canvas::addPlacementFactory("scenery-object", &addSceneObjectPlacement);
|
sc::Canvas::addPlacementFactory("scenery-object", &addSceneObjectPlacement);
|
||||||
sc::Canvas::addPlacementFactory("dynamic-model", &addDynamicModelPlacement);
|
sc::Canvas::addPlacementFactory("dynamic-model", &addDynamicModelPlacement);
|
||||||
}
|
|
||||||
}
|
|
||||||
simgear::canvas::CanvasMgr::init();
|
simgear::canvas::CanvasMgr::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,8 +120,6 @@ void CanvasMgr::shutdown()
|
||||||
sc::Canvas::removePlacementFactory("object");
|
sc::Canvas::removePlacementFactory("object");
|
||||||
sc::Canvas::removePlacementFactory("scenery-object");
|
sc::Canvas::removePlacementFactory("scenery-object");
|
||||||
sc::Canvas::removePlacementFactory("dynamic-model");
|
sc::Canvas::removePlacementFactory("dynamic-model");
|
||||||
|
|
||||||
_gui_camera = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -147,8 +139,8 @@ CanvasMgr::getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const
|
||||||
// if( contexts.empty() )
|
// if( contexts.empty() )
|
||||||
// return 0;
|
// return 0;
|
||||||
|
|
||||||
osg::ref_ptr<osg::Camera> guiCamera;
|
osg::Camera* guiCamera = flightgear::getGUICamera(flightgear::CameraGroup::getDefault());
|
||||||
if( !_gui_camera.lock(guiCamera) )
|
if (!guiCamera)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
osg::State* state = guiCamera->getGraphicsContext()->getState(); //contexts[0]->getState();
|
osg::State* state = guiCamera->getGraphicsContext()->getState(); //contexts[0]->getState();
|
||||||
|
|
|
@ -47,7 +47,6 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
osg::observer_ptr<osg::Camera> _gui_camera;
|
|
||||||
SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit;
|
SGPropertyChangeCallback<CanvasMgr> _cb_model_reinit;
|
||||||
|
|
||||||
void handleModelReinit(SGPropertyNode*);
|
void handleModelReinit(SGPropertyNode*);
|
||||||
|
|
Loading…
Reference in a new issue