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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy2/src/util/SignalHandler.h

    r2171 r2344  
    3737#include "UtilPrereqs.h"
    3838
     39#include <cassert>
    3940#include <list>
    4041#include <string>
     
    6869    class SignalHandler
    6970    {
    70     private:
    71         SignalHandler();
    7271    public:
    73         inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
    74         ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
     72        SignalHandler()  { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; }
     73        ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = NULL; }
     74        inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; }
    7575
    7676        void registerCallback( SignalCallback cb, void * someData );
     
    8787        SignalCallbackList callbackList;
    8888
    89         static SignalHandler * singletonRef;
     89        static SignalHandler* singletonRef_s;
    9090
    9191        std::string appName;
     
    104104    {
    105105    public:
    106         inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
    107         void doCatch( const std::string & appName, const std::string & filename ) {};
    108         void dontCatch() {};
    109         void registerCallback( SignalCallback cb, void * someData ) {};
     106        SignalHandler()  { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; }
     107        ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = 0; }
     108        inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; }
     109        void doCatch( const std::string & appName, const std::string & filename ) {}
     110        void dontCatch() {}
     111        void registerCallback( SignalCallback cb, void * someData ) {}
    110112
    111113    private:
    112         static SignalHandler * singletonRef;
     114        static SignalHandler* singletonRef_s;
    113115    };
    114116}
Note: See TracChangeset for help on using the changeset viewer.