Reset: explicit close-window function.
Allow orderly shutdown of OSG before cxa_finalize
This commit is contained in:
parent
58fa30b24d
commit
af40bcb60e
5 changed files with 25 additions and 2 deletions
|
@ -59,6 +59,7 @@ enum { KEYMOD_NONE = 0,
|
|||
|
||||
void fgOSInit(int* argc, char** argv);
|
||||
void fgOSOpenWindow(bool stencil);
|
||||
void fgOSCloseWindow();
|
||||
void fgOSFullScreen();
|
||||
int fgOSMainLoop();
|
||||
void fgOSExit(int code);
|
||||
|
|
|
@ -391,6 +391,7 @@ int fgMainInit( int argc, char **argv ) {
|
|||
|
||||
// pass control off to the master event handler
|
||||
int result = fgOSMainLoop();
|
||||
fgOSCloseWindow();
|
||||
|
||||
// clean up here; ensure we null globals to avoid
|
||||
// confusing the atexit() handler
|
||||
|
|
|
@ -379,9 +379,17 @@ bool FGScenery::scenery_available(const SGGeod& position, double range_m)
|
|||
return false;
|
||||
}
|
||||
|
||||
static osg::ref_ptr<SceneryPager> pager;
|
||||
|
||||
SceneryPager* FGScenery::getPagerSingleton()
|
||||
{
|
||||
static osg::ref_ptr<SceneryPager> pager = new SceneryPager;
|
||||
if (!pager)
|
||||
pager = new SceneryPager;
|
||||
return pager.get();
|
||||
}
|
||||
|
||||
void FGScenery::resetPagerSingleton()
|
||||
{
|
||||
pager = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,8 @@ public:
|
|||
// Static because access to the pager is needed before the rest of
|
||||
// the scenery is initialized.
|
||||
static flightgear::SceneryPager* getPagerSingleton();
|
||||
static void resetPagerSingleton();
|
||||
|
||||
flightgear::SceneryPager* getPager() { return _pager.get(); }
|
||||
};
|
||||
|
||||
|
|
|
@ -386,6 +386,15 @@ void fgOSInit(int* argc, char** argv)
|
|||
WindowSystemAdapter::setWSA(new WindowSystemAdapter);
|
||||
}
|
||||
|
||||
void fgOSCloseWindow()
|
||||
{
|
||||
FGScenery::resetPagerSingleton();
|
||||
mainCamera = NULL;
|
||||
flightgear::CameraGroup::setDefault(NULL);
|
||||
WindowSystemAdapter::setWSA(NULL);
|
||||
viewer = NULL;
|
||||
}
|
||||
|
||||
void fgOSFullScreen()
|
||||
{
|
||||
std::vector<osgViewer::GraphicsWindow*> windows;
|
||||
|
@ -521,7 +530,9 @@ static int _cursor = -1;
|
|||
void fgSetMouseCursor(int cursor)
|
||||
{
|
||||
_cursor = cursor;
|
||||
|
||||
if (!viewer)
|
||||
return;
|
||||
|
||||
std::vector<osgViewer::GraphicsWindow*> windows;
|
||||
viewer->getWindows(windows);
|
||||
BOOST_FOREACH(osgViewer::GraphicsWindow* gw, windows) {
|
||||
|
|
Loading…
Add table
Reference in a new issue