From 44643839be782e8b2cb487d8664d28cfc14491f1 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 16 Jul 2012 06:16:43 +0200 Subject: [PATCH] CHANGED: #1471 The local string mapper is now instantiated by CWidgetManager. --HG-- branch : gui-refactoring --- code/nel/include/nel/gui/interface_element.h | 5 ++++- code/nel/src/gui/interface_element.cpp | 15 +++++++++++++-- code/nel/src/gui/widget_manager.cpp | 4 ++++ .../src/interface_v3/interface_manager.cpp | 17 ----------------- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h index b5aa6fcb0..095fef7c3 100644 --- a/code/nel/include/nel/gui/interface_element.h +++ b/code/nel/include/nel/gui/interface_element.h @@ -521,7 +521,6 @@ namespace NLGUI TLinkVect *_Links; // links, or NULL if no link }; - extern NLMISC::CStringMapper *_UIStringMapper; /** * class to compress string usage in the interface * \author Matthieu 'Trap' Besson @@ -586,9 +585,13 @@ namespace NLGUI } } + static void createStringMapper(); + static void deleteStringMapper(); + private: NLMISC::TStringId _Id; + static NLMISC::CStringMapper *_UIStringMapper; }; inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); } diff --git a/code/nel/src/gui/interface_element.cpp b/code/nel/src/gui/interface_element.cpp index 0149b739b..affc6ef31 100644 --- a/code/nel/src/gui/interface_element.cpp +++ b/code/nel/src/gui/interface_element.cpp @@ -32,8 +32,6 @@ using namespace NLMISC; namespace NLGUI { - CStringMapper *_UIStringMapper = NULL; - // ------------------------------------------------------------------------------------------------ CInterfaceElement::~CInterfaceElement() { @@ -1271,6 +1269,19 @@ namespace NLGUI return false; } + CStringMapper* CStringShared::_UIStringMapper = NULL; + + + void CStringShared::createStringMapper() + { + if( _UIStringMapper == NULL ) + _UIStringMapper = CStringMapper::createLocalMapper(); + } + + void CStringShared::deleteStringMapper() + { + delete _UIStringMapper; + } } diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 4cee9f340..8710e530a 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -3093,6 +3093,8 @@ namespace NLGUI CWidgetManager::CWidgetManager() { + CStringShared::createStringMapper(); + CReflectableRegister::registerClasses(); parser = IParser::createParser(); @@ -3133,6 +3135,8 @@ namespace NLGUI _Pointer = NULL; curContextHelp = NULL; + + CStringShared::deleteStringMapper(); } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index f537cc383..75452bf2d 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -137,7 +137,6 @@ using namespace NLMISC; namespace NLGUI { extern void luaDebuggerMainLoop(); - extern NLMISC::CStringMapper *_UIStringMapper; } extern CClientChatManager ChatMngr; @@ -543,10 +542,6 @@ CInterfaceManager::~CInterfaceManager() CViewTextFormated::setFormatter( NULL ); reset(); // to flush IDStringWaiters - // release the local string mapper - delete _UIStringMapper; - _UIStringMapper = NULL; - // release the database observers releaseServerToLocalAutoCopyObservers(); @@ -636,10 +631,6 @@ void CInterfaceManager::initLogin() // Init LUA Scripting initLUA(); - // Create String mapper - if (_UIStringMapper == NULL) - _UIStringMapper = CStringMapper::createLocalMapper(); - // Clear the action manager Actions.clear(); EditActions.clear(); @@ -708,10 +699,6 @@ void CInterfaceManager::uninitLogin() // ------------------------------------------------------------------------------------------------ void CInterfaceManager::initOutGame() { - // create String mapper - if (_UIStringMapper == NULL) - _UIStringMapper = CStringMapper::createLocalMapper(); - // Clear the action manager Actions.clear(); EditActions.clear(); @@ -871,10 +858,6 @@ void CInterfaceManager::initInGame() // Init LUA Scripting initLUA(); - // create the _UIStringMapper - if (_UIStringMapper == NULL) - _UIStringMapper = CStringMapper::createLocalMapper(); - // Clear the action manager Actions.clear(); EditActions.clear();