Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 24, 2008, 10:40:22 PM (16 years ago)
Author:
rgrieder
Message:
  • privatised InputState c'tors
  • added destruction code for GUIManager
  • fixed some issues and bugs
  • found 2400 memory leaks ;)
  • haven't done anything about it
  • converted GUIManager to Ogre Singleton
  • added NULL checkers in Loader
Location:
code/branches/gui/src/orxonox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/orxonox/Orxonox.cc

    r1645 r1646  
    115115    , inputManager_(0)
    116116    , radar_(0)
     117    , console_(0)
     118    , guiManager_(0)
    117119  {
    118120    RegisterRootObject(Orxonox);
     
    142144    if (this->radar_)
    143145      delete this->radar_;
     146
     147    if (this->guiManager_)
     148      delete guiManager_;
    144149
    145150    //if (this->auMan_)
     
    271276
    272277          // load the CEGUI interface
    273           GUIManager::getInstance().initialise();
     278          guiManager_ = new GUIManager();
     279          guiManager_->initialise();
    274280        }
    275281
  • code/branches/gui/src/orxonox/Orxonox.h

    r1642 r1646  
    103103      Radar*                radar_;         //!< represents the Radar (not the HUD part)
    104104      InGameConsole*        console_;
     105      GUIManager*           guiManager_;
    105106
    106107      static Orxonox *singletonRef_s;
  • code/branches/gui/src/orxonox/OrxonoxPrereqs.h

    r1625 r1646  
    118118    class OverlayGroup;
    119119    class OverlayText;
     120
     121    //gui
     122    class GUIManager;
    120123}
    121124
  • code/branches/gui/src/orxonox/gui/GUIManager.cc

    r1645 r1646  
    5858    SetConsoleCommandShortcut(GUIManager, showGUI_s).setKeybindMode(KeybindMode::OnPress);
    5959
     60    GUIManager* GUIManager::singletonRef_s = 0;
     61
    6062    GUIManager::GUIManager()
    6163        //: emptySceneManager_(0)
     
    7173        , state_(Uninitialised)
    7274    {
     75        assert(singletonRef_s == 0);
     76        singletonRef_s = this;
    7377    }
    7478
    7579    GUIManager::~GUIManager()
    7680    {
    77         // TODO: destruct at least something
     81        if (backgroundCamera_)
     82            backgroundSceneManager_->destroyCamera(backgroundCamera_);
     83
     84        if (backgroundSceneManager_)
     85            Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);
     86
     87        InputManager::getInstance().destroyState("gui");
     88
     89        if (guiSystem_)
     90            delete guiSystem_;
     91
     92        if (scriptModule_)
     93        {
     94            // destroy our own tolua interfaces
     95                //lua_pushnil(luaState_);
     96                //lua_setglobal(luaState_, "Orxonox");
     97                //lua_pushnil(luaState_);
     98                //lua_setglobal(luaState_, "Core");
     99            // TODO: deleting the script module fails an assertation.
     100            // However there is not much we can do about it since it occurs too when
     101            // we don't open Core or Orxonox. Might be a CEGUI issue.
     102            // The memory leak is not a problem anyway..
     103            //delete scriptModule_;
     104        }
     105
     106        if (guiRenderer_)
     107            delete guiRenderer_;
     108
     109        singletonRef_s = 0;
    78110    }
    79111
     
    104136                // setup scripting
    105137                this->scriptModule_ = new LuaScriptModule();
     138                this->luaState_ = this->scriptModule_->getLuaState();
    106139
    107140                // create the CEGUI system singleton
     
    267300
    268301
    269     /**
    270     @brief
    271         Returns a unique instance of GUIManager.
    272     @return
    273         The instance
    274     */
    275     GUIManager& GUIManager::getInstance()
    276     {
    277         static GUIManager instance;
    278         return instance;
    279     }
    280 
    281302    inline CEGUI::MouseButton GUIManager::convertButton(MouseButton::Enum button)
    282303    {
  • code/branches/gui/src/orxonox/gui/GUIManager.h

    r1641 r1646  
    4848    class LuaScriptModule;
    4949}
     50struct lua_State;
    5051
    5152namespace orxonox // tolua_export
     
    6869        };
    6970
     71        GUIManager();
     72        ~GUIManager();
     73
    7074        bool initialise();
    7175        void tick(float dt);
     
    7579        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
    7680
    77         static GUIManager& getInstance(); // tolua_export
    7881        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
    7982        {
     
    8184        }
    8285
     86        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
     87        static GUIManager* getInstancePtr() { return singletonRef_s; }
     88
    8389    private:
    84         GUIManager();
    8590        GUIManager(const GUIManager& instance);
    86         ~GUIManager();
    8791
    8892        void keyPressed (const KeyEvent& evt)
     
    119123        CEGUI::System*            guiSystem_;
    120124        CEGUI::Imageset*          backgroundImage_;
     125        lua_State*                luaState_;
    121126
    122127        State state_;
    123128
     129        static CEGUI::MouseButton convertButton(MouseButton::Enum button);
    124130
    125         static CEGUI::MouseButton convertButton(MouseButton::Enum button);
     131        static GUIManager*        singletonRef_s;
    126132    }; // tolua_export
    127133
Note: See TracChangeset for help on using the changeset viewer.