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/Core.cc

    r2171 r2344  
    4646    bool Core::bIsMaster_s      = false;
    4747
     48    Core* Core::singletonRef_s = 0;
     49
    4850    /**
    4951        @brief Constructor: Registers the object and sets the config-values.
     
    5355    {
    5456        RegisterRootObject(Core);
     57
     58        assert(singletonRef_s == 0);
     59        singletonRef_s = this;
     60
    5561        this->setConfigValues();
    56         isCreatingCoreSettings() = false;
    5762    }
    5863
     
    6267    Core::~Core()
    6368    {
    64         isCreatingCoreSettings() = true;
    65     }
    66 
    67     /**
    68         @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value.
    69     */
    70     bool& Core::isCreatingCoreSettings()
    71     {
    72         static bool bCreatingCoreSettings = true;
    73         return bCreatingCoreSettings;
    74     }
    75 
    76     /**
    77         @brief Returns a unique instance of Core.
    78         @return The instance
    79     */
    80     Core& Core::getInstance()
    81     {
    82         // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class
    83         //if (Core::isCreatingCoreSettings())
    84         //{
    85         //    isCreatingCoreSettings() = false;
    86         //    //instance.setConfigValues();
    87         //}
    88 
    89         static bool firstTime = true;
    90         if (firstTime)
    91             isCreatingCoreSettings() = true;
    92 
    93         static Core instance;
    94         return instance;
     69        assert(singletonRef_s);
     70        singletonRef_s = 0;
    9571    }
    9672
     
    140116    int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
    141117    {
    142         if (!Core::isCreatingCoreSettings())
     118        switch (device)
    143119        {
    144             switch (device)
    145             {
    146             case OutputHandler::LD_All:
    147                 return Core::getInstance().softDebugLevel_;
    148             case OutputHandler::LD_Console:
    149                 return Core::getInstance().softDebugLevelConsole_;
    150             case OutputHandler::LD_Logfile:
    151                 return Core::getInstance().softDebugLevelLogfile_;
    152             case OutputHandler::LD_Shell:
    153                 return Core::getInstance().softDebugLevelShell_;
    154             default:
    155                 assert(0);
    156             }
     120        case OutputHandler::LD_All:
     121            return Core::getInstance().softDebugLevel_;
     122        case OutputHandler::LD_Console:
     123            return Core::getInstance().softDebugLevelConsole_;
     124        case OutputHandler::LD_Logfile:
     125            return Core::getInstance().softDebugLevelLogfile_;
     126        case OutputHandler::LD_Shell:
     127            return Core::getInstance().softDebugLevelShell_;
     128        default:
     129            assert(0);
     130            return 2;
    157131        }
    158 
    159         // Return a constant value while we're creating the object
    160         return 2;
    161132    }
    162133
     
    168139     void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    169140     {
    170         if (!Core::isCreatingCoreSettings())
    171         {
    172             if (device == OutputHandler::LD_All)
    173                 Core::getInstance().softDebugLevel_ = level;
    174             else if (device == OutputHandler::LD_Console)
    175                 Core::getInstance().softDebugLevelConsole_ = level;
    176             else if (device == OutputHandler::LD_Logfile)
    177                 Core::getInstance().softDebugLevelLogfile_ = level;
    178             else if (device == OutputHandler::LD_Shell)
    179                 Core::getInstance().softDebugLevelShell_ = level;
     141        if (device == OutputHandler::LD_All)
     142            Core::getInstance().softDebugLevel_ = level;
     143        else if (device == OutputHandler::LD_Console)
     144            Core::getInstance().softDebugLevelConsole_ = level;
     145        else if (device == OutputHandler::LD_Logfile)
     146            Core::getInstance().softDebugLevelLogfile_ = level;
     147        else if (device == OutputHandler::LD_Shell)
     148            Core::getInstance().softDebugLevelShell_ = level;
    180149
    181             OutputHandler::setSoftDebugLevel(device, level);
    182         }
     150        OutputHandler::setSoftDebugLevel(device, level);
    183151     }
    184152
     
    188156    const std::string& Core::getLanguage()
    189157    {
    190         if (!Core::isCreatingCoreSettings())
    191             return Core::getInstance().language_;
    192 
    193         return Language::getLanguage().defaultLanguage_;
     158        return Core::getInstance().language_;
    194159    }
    195160
Note: See TracChangeset for help on using the changeset viewer.