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/core/Identifier.cc

    r2171 r2344  
    9393        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
    9494            delete (it->second);
     95        for (std::vector<Functor*>::iterator it = this->constructionCallbacks_.begin(); it != this->constructionCallbacks_.end(); ++it)
     96            delete *it;
     97    }
     98
     99    /**
     100        @brief Returns the identifier map with the names as received by typeid(). This is only used internally.
     101    */
     102    std::map<std::string, Identifier*>& Identifier::getTypeIDIdentifierMap()
     103    {
     104        static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
     105        return identifiers;
    95106    }
    96107
     
    103114    Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)
    104115    {
    105         static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
    106         std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name);
    107 
    108         if (it != identifiers.end())
     116        std::map<std::string, Identifier*>::const_iterator it = getTypeIDIdentifierMap().find(name);
     117
     118        if (it != getTypeIDIdentifierMap().end())
    109119        {
    110120            // There is already an entry: return it and delete the proposal
     
    115125        {
    116126            // There is no entry: put the proposal into the map and return it
    117             identifiers[name] = proposal;
     127            getTypeIDIdentifierMap()[name] = proposal;
    118128            return proposal;
    119129        }
     
    192202    void Identifier::destroyAllIdentifiers()
    193203    {
    194         for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)
     204        for (std::map<std::string, Identifier*>::iterator it = Identifier::getTypeIDIdentifierMap().begin(); it != Identifier::getTypeIDIdentifierMap().end(); ++it)
    195205            delete (it->second);
    196206    }
Note: See TracChangeset for help on using the changeset viewer.