Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2927 for code/trunk/src/core


Ignore:
Timestamp:
Apr 19, 2009, 10:59:59 PM (16 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/core
Files:
2 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_;
Note: See TracChangeset for help on using the changeset viewer.