[Orxonox-commit 1154] r5875 - code/branches/core5/src/libraries/core

rgrieder at orxonox.net rgrieder at orxonox.net
Sun Oct 4 23:05:17 CEST 2009


Author: rgrieder
Date: 2009-10-04 23:05:17 +0200 (Sun, 04 Oct 2009)
New Revision: 5875

Modified:
   code/branches/core5/src/libraries/core/Core.cc
   code/branches/core5/src/libraries/core/Game.cc
   code/branches/core5/src/libraries/core/GameMode.h
Log:
Fixed an issue that could occur when singletons associated with ScopeID::Graphics (indirectly) asked for GameMode::showsGraphics.

Modified: code/branches/core5/src/libraries/core/Core.cc
===================================================================
--- code/branches/core5/src/libraries/core/Core.cc	2009-10-04 19:51:14 UTC (rev 5874)
+++ code/branches/core5/src/libraries/core/Core.cc	2009-10-04 21:05:17 UTC (rev 5875)
@@ -292,12 +292,13 @@
         guiManager_.reset(new GUIManager(graphicsManager_->getRenderWindow(),
             inputManager_->getMousePosition(), graphicsManager_->isFullScreen()));
 
+        bGraphicsLoaded_ = true;
+        GameMode::bShowsGraphics_s = true;
+
         // Create singletons associated with graphics (in other libraries)
         graphicsScope_.reset(new Scope<ScopeID::Graphics>());
 
         unloader.Dismiss();
-
-        bGraphicsLoaded_ = true;
     }
 
     void Core::unloadGraphics()
@@ -319,6 +320,7 @@
         }
 
         bGraphicsLoaded_ = false;
+        GameMode::bShowsGraphics_s = false;
     }
 
     /**

Modified: code/branches/core5/src/libraries/core/Game.cc
===================================================================
--- code/branches/core5/src/libraries/core/Game.cc	2009-10-04 19:51:14 UTC (rev 5874)
+++ code/branches/core5/src/libraries/core/Game.cc	2009-10-04 21:05:17 UTC (rev 5875)
@@ -522,11 +522,10 @@
 
     void Game::loadGraphics()
     {
-        if (!GameMode::bShowsGraphics_s)
+        if (!GameMode::showsGraphics())
         {
             core_->loadGraphics();
             Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
-            GameMode::bShowsGraphics_s = true;
 
             // Construct all the GameStates that require graphics
             for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
@@ -547,7 +546,7 @@
 
     void Game::unloadGraphics()
     {
-        if (GameMode::bShowsGraphics_s)
+        if (GameMode::showsGraphics())
         {
             // Destroy all the GameStates that require graphics
             for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)
@@ -559,7 +558,6 @@
             }
 
             core_->unloadGraphics();
-            GameMode::bShowsGraphics_s = false;
         }
     }
 

Modified: code/branches/core5/src/libraries/core/GameMode.h
===================================================================
--- code/branches/core5/src/libraries/core/GameMode.h	2009-10-04 19:51:14 UTC (rev 5874)
+++ code/branches/core5/src/libraries/core/GameMode.h	2009-10-04 21:05:17 UTC (rev 5875)
@@ -40,7 +40,7 @@
 {
     class _CoreExport GameMode
     {
-        friend class Game;
+        friend class Core;
 
         public:
             static bool showsGraphics() { return bShowsGraphics_s; }




More information about the Orxonox-commit mailing list