Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2927


Ignore:
Timestamp:
Apr 19, 2009, 10:59:59 PM (15 years ago)
Author:
rgrieder
Message:

Fixed three memory leaks and a bug.
@beni: Is deleting the "startGame" console command a problem or did we just forget to remove the comment characters?

Location:
code/trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/Game.cc

    r2896 r2927  
    106106        delete this->core_;
    107107
    108         // Delete all GameStates created by the macros
    109         for (std::map<std::string, GameState*>::const_iterator it = allStates_s.begin(); it != allStates_s.end(); ++it)
    110             delete it->second;
     108        // Delete all the created nodes
     109        for (std::vector<GameStateTreeNode*>::const_iterator it = this->allStateNodes_.begin(); it != this->allStateNodes_.end(); ++it)
     110            delete *it;
    111111
    112112        delete this->gameClock_;
     
    320320                    ThrowException(GameState, "No two root GameStates are allowed!");
    321321                GameStateTreeNode* newNode = new GameStateTreeNode;
     322                this->allStateNodes_.push_back(newNode);
    322323                newNode->state_ = newState;
    323324                newNode->parent_ = 0;
     
    328329            {
    329330                GameStateTreeNode* newNode = new GameStateTreeNode;
     331                this->allStateNodes_.push_back(newNode);
    330332                newNode->state_ = newState;
    331333                if (newLevel < currentLevel)
     
    391393        return true;
    392394    }
     395
     396    /*static*/ void Game::destroyStates()
     397    {
     398        // Delete all GameStates created by the macros
     399        for (std::map<std::string, GameState*>::const_iterator it = allStates_s.begin(); it != allStates_s.end(); ++it)
     400            delete it->second;
     401        allStates_s.clear();
     402    }
    393403}
  • code/trunk/src/core/Game.h

    r2896 r2927  
    7777
    7878        static bool addGameState(GameState* state);
     79        static void destroyStates();
    7980        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
    8081
     
    9596        GameStateTreeNode*              activeStateNode_;
    9697        std::vector<GameStateTreeNode*> requestedStateNodes_;
     98        std::vector<GameStateTreeNode*> allStateNodes_;
    9799
    98100        Core*                           core_;
  • code/trunk/src/orxonox/Main.cc

    r2896 r2927  
    6969
    7070        orxonox.run();
     71
     72        // destroy the GameStates created pre-mainly
     73        orxonox::Game::destroyStates();
    7174    } // orxonox gets destroyed right here!
    7275
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r2896 r2927  
    8686        InputManager::getInstance().requestDestroyState("mainMenu");
    8787
    88 /*
     88        GUIManager::getInstance().setCamera(0);
     89        GraphicsManager::getInstance().setCamera(0);
     90        this->scene_->getSceneManager()->destroyCamera(this->camera_);
     91        delete this->scene_;
     92
    8993        if (this->ccStartGame_)
    9094        {
     
    9296            this->ccStartGame_ = 0;
    9397        }
    94 */
    9598    }
    9699
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r2896 r2927  
    252252    void GUIManager::setCamera(Ogre::Camera* camera)
    253253    {
    254         this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
     254        if (camera == NULL)
     255            this->guiRenderer_->setTargetSceneManager(0);
     256        else
     257            this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
    255258    }
    256259
Note: See TracChangeset for help on using the changeset viewer.