Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 4, 2008, 8:28:14 PM (16 years ago)
Author:
rgrieder
Message:

Completed destruction of static elements like XMLPort, Identifier, etc.
Of initially about 250 memory leaks (not in the actual meaning but the memory was never freed anyway) only 1 remains in TinyCpp.

  • Core class is now a normal Singleton that gets created and destroyed in main.
  • The same goes for Language, LuaBind, SignalHandler and PlayerManager.
  • Added a new std::set to the CommandExecutor so that the external ConsoleCommands can get destroyed too.
  • Code for destroying CommandLineArguments
  • Added destruction code for ConstructionCallbacks in Identifier
  • Moved internal identifier map (the one with the typeid(.) names) in a static function in Identifier. This was necessary in order to destroy ALL Identifiers with the static destruction function. Before it was possible to create an Identifier with having a class instance (that would call RegisterObject) for instance by simply accessing it via getIdentifier.
  • Removed a big memory leak in Button (forgot to destroy the ConfigValueContainers)
  • Added destruction code for InputBufferListenerTuples in InputBuffer destructor.
  • Added destruction code for load and save executors in both XMLPortParam and XMLPortObject
  • Added destruction code for ConsoleCommands in GSRoot, GSGraphics and GSLevel (temporary solution anyway)
  • Deleting the CEGUILua script module seems to work properly now, one memory leak less (GUIManager.cc)
  • Added global destruction calls in Main.cc
Location:
code/branches/objecthierarchy2/src/orxonox/gamestates
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSGraphics.cc

    r2171 r2344  
    164164        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
    165165        functor1->setObject(this);
    166         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen"));
     166        ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
     167        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
    167168    }
    168169
     
    170171    {
    171172        using namespace Ogre;
     173
     174        delete this->ccPrintScreen_;
    172175
    173176        // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSGraphics.h

    r2103 r2344  
    112112        unsigned int          detailLevelParticle_;      //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
    113113        std::string           defaultMasterKeybindings_; //!< Filename of default master keybindings.
     114
     115        // console commands
     116        ConsoleCommand*       ccPrintScreen_;
    114117    };
    115118}
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.cc

    r2173 r2344  
    4747#include "CameraManager.h"
    4848#include "LevelManager.h"
     49#include "PlayerManager.h"
    4950#include "Settings.h"
    5051
     
    99100            // create the global LevelManager
    100101            this->levelManager_ = new LevelManager();
     102            this->playerManager_ = new PlayerManager();
    101103
    102104            // reset game speed to normal
     
    114116            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    115117            functor1->setObject(this);
    116             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     118            ccKeybind_ = createConsoleCommand(functor1, "keybind");
     119            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
    117120            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    118121            functor2->setObject(this);
    119             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     122            ccTkeybind_ = createConsoleCommand(functor2, "tkeybind");
     123            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
    120124            // set our console command as callback for the key detector
    121125            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     
    130134            FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    131135            functor->setObject(this);
    132             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
     136            ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor");
     137            CommandExecutor::addConsoleCommandShortcut(ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    133138        }
    134139    }
     
    136141    void GSLevel::leave()
    137142    {
     143        // destroy console commands
     144        delete this->ccKeybind_;
     145        delete this->ccSetTimeFactor_;
     146        delete this->ccTkeybind_;
     147
    138148        // this call will delete every BaseObject!
    139149        // But currently this will call methods of objects that exist no more
     
    156166        if (this->levelManager_)
    157167            delete this->levelManager_;
     168
     169        if (this->playerManager_)
     170            delete this->playerManager_;
    158171
    159172        if (Core::showsGraphics())
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSLevel.h

    r2103 r2344  
    7070        CameraManager*        cameraManager_;
    7171        LevelManager*         levelManager_;
     72        PlayerManager*        playerManager_;
    7273
    7374        //##### ConfigValues #####
     
    7576        //! Filename of default keybindings.
    7677        std::string           defaultKeybindings_;
     78
     79        // console commands
     80        ConsoleCommand*       ccKeybind_;
     81        ConsoleCommand*       ccTkeybind_;
     82        ConsoleCommand*       ccSetTimeFactor_;
    7783
    7884    private:
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.cc

    r2171 r2344  
    4040#include "core/TclBind.h"
    4141#include "core/TclThreadManager.h"
     42#include "core/LuaBind.h"
    4243#include "tools/Timer.h"
    4344#include "objects/Tickable.h"
     
    8788        // creates the class hierarchy for all classes with factories
    8889        Factory::createClassHierarchy();
     90
     91        // Create the lua interface
     92        this->luaBind_ = new LuaBind();
    8993
    9094        // instantiate Settings class
     
    117121        FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame);
    118122        functor1->setObject(this);
    119         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit"));
     123        ccExit_ = createConsoleCommand(functor1, "exit");
     124        CommandExecutor::addConsoleCommandShortcut(ccExit_);
    120125
    121126        // add console commands
    122127        FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState);
    123128        functor2->setObject(this);
    124         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState"));
     129        ccSelectGameState_ = createConsoleCommand(functor2, "selectGameState");
     130        CommandExecutor::addConsoleCommandShortcut(ccSelectGameState_);
    125131    }
    126132
    127133    void GSRoot::leave()
    128134    {
    129         // TODO: remove and destroy console commands
     135        // destroy console commands
     136        delete this->ccExit_;
     137        delete this->ccSelectGameState_;
    130138
    131139        delete this->shell_;
     
    133141        delete this->tclBind_;
    134142
    135         delete settings_;
    136 
     143        delete this->settings_;
     144        delete this->luaBind_;
    137145    }
    138146
  • code/branches/objecthierarchy2/src/orxonox/gamestates/GSRoot.h

    r1891 r2344  
    5959        TclThreadManager*     tclThreadManager_;
    6060        Shell*                shell_;
     61        LuaBind*              luaBind_;
     62
     63        // console commands
     64        ConsoleCommand*       ccExit_;
     65        ConsoleCommand*       ccSelectGameState_;
    6166    };
    6267}
Note: See TracChangeset for help on using the changeset viewer.