CHANGED: #1471 The local string mapper is now instantiated by CWidgetManager.

--HG--
branch : gui-refactoring
hg/feature/sse2
dfighter1985 13 years ago
parent 63f7fa81e9
commit 44643839be

@ -521,7 +521,6 @@ namespace NLGUI
TLinkVect *_Links; // links, or NULL if no link TLinkVect *_Links; // links, or NULL if no link
}; };
extern NLMISC::CStringMapper *_UIStringMapper;
/** /**
* class to compress string usage in the interface * class to compress string usage in the interface
* \author Matthieu 'Trap' Besson * \author Matthieu 'Trap' Besson
@ -586,9 +585,13 @@ namespace NLGUI
} }
} }
static void createStringMapper();
static void deleteStringMapper();
private: private:
NLMISC::TStringId _Id; NLMISC::TStringId _Id;
static NLMISC::CStringMapper *_UIStringMapper;
}; };
inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); } inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }

@ -32,8 +32,6 @@ using namespace NLMISC;
namespace NLGUI namespace NLGUI
{ {
CStringMapper *_UIStringMapper = NULL;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
CInterfaceElement::~CInterfaceElement() CInterfaceElement::~CInterfaceElement()
{ {
@ -1271,6 +1269,19 @@ namespace NLGUI
return false; return false;
} }
CStringMapper* CStringShared::_UIStringMapper = NULL;
void CStringShared::createStringMapper()
{
if( _UIStringMapper == NULL )
_UIStringMapper = CStringMapper::createLocalMapper();
}
void CStringShared::deleteStringMapper()
{
delete _UIStringMapper;
}
} }

@ -3093,6 +3093,8 @@ namespace NLGUI
CWidgetManager::CWidgetManager() CWidgetManager::CWidgetManager()
{ {
CStringShared::createStringMapper();
CReflectableRegister::registerClasses(); CReflectableRegister::registerClasses();
parser = IParser::createParser(); parser = IParser::createParser();
@ -3133,6 +3135,8 @@ namespace NLGUI
_Pointer = NULL; _Pointer = NULL;
curContextHelp = NULL; curContextHelp = NULL;
CStringShared::deleteStringMapper();
} }
} }

@ -137,7 +137,6 @@ using namespace NLMISC;
namespace NLGUI namespace NLGUI
{ {
extern void luaDebuggerMainLoop(); extern void luaDebuggerMainLoop();
extern NLMISC::CStringMapper *_UIStringMapper;
} }
extern CClientChatManager ChatMngr; extern CClientChatManager ChatMngr;
@ -543,10 +542,6 @@ CInterfaceManager::~CInterfaceManager()
CViewTextFormated::setFormatter( NULL ); CViewTextFormated::setFormatter( NULL );
reset(); // to flush IDStringWaiters reset(); // to flush IDStringWaiters
// release the local string mapper
delete _UIStringMapper;
_UIStringMapper = NULL;
// release the database observers // release the database observers
releaseServerToLocalAutoCopyObservers(); releaseServerToLocalAutoCopyObservers();
@ -636,10 +631,6 @@ void CInterfaceManager::initLogin()
// Init LUA Scripting // Init LUA Scripting
initLUA(); initLUA();
// Create String mapper
if (_UIStringMapper == NULL)
_UIStringMapper = CStringMapper::createLocalMapper();
// Clear the action manager // Clear the action manager
Actions.clear(); Actions.clear();
EditActions.clear(); EditActions.clear();
@ -708,10 +699,6 @@ void CInterfaceManager::uninitLogin()
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceManager::initOutGame() void CInterfaceManager::initOutGame()
{ {
// create String mapper
if (_UIStringMapper == NULL)
_UIStringMapper = CStringMapper::createLocalMapper();
// Clear the action manager // Clear the action manager
Actions.clear(); Actions.clear();
EditActions.clear(); EditActions.clear();
@ -871,10 +858,6 @@ void CInterfaceManager::initInGame()
// Init LUA Scripting // Init LUA Scripting
initLUA(); initLUA();
// create the _UIStringMapper
if (_UIStringMapper == NULL)
_UIStringMapper = CStringMapper::createLocalMapper();
// Clear the action manager // Clear the action manager
Actions.clear(); Actions.clear();
EditActions.clear(); EditActions.clear();

Loading…
Cancel
Save