From 8cc3963dddb85d4623722eb99d9c8eea35c407d6 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 4 Dec 2016 16:52:50 +0100 Subject: [PATCH] Fixed: Respect coding standard for "parser" variable and delete it in destructor (fix a memory leak) --HG-- branch : develop --- code/nel/include/nel/gui/widget_manager.h | 4 ++-- code/nel/src/gui/widget_manager.cpp | 17 +++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index 2f9220cda..4d96be1b5 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -502,7 +502,7 @@ namespace NLGUI const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; } - IParser* getParser() const{ return parser; } + IParser* getParser() const{ return _Parser; } /// Retrieves the Id of the currently selected widgets void getEditorSelection( std::vector< std::string > &selection ); @@ -536,7 +536,7 @@ namespace NLGUI CWidgetManager(); ~CWidgetManager(); - IParser *parser; + IParser *_Parser; static CWidgetManager *instance; std::vector< SMasterGroup > _MasterGroups; diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp index 5ef9ee622..73c7098fe 100644 --- a/code/nel/src/gui/widget_manager.cpp +++ b/code/nel/src/gui/widget_manager.cpp @@ -466,7 +466,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ CInterfaceElement* CWidgetManager::getElementFromDefine( const std::string &defineId ) { - return getElementFromId( parser->getDefine( defineId ) ); + return getElementFromId( _Parser->getDefine( defineId ) ); } // ------------------------------------------------------------------------------------------------ @@ -2113,8 +2113,6 @@ namespace NLGUI bool handled = false; - CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() ); - if( evnt.getType() == CEventDescriptor::system ) { handleSystemEvent( evnt ); @@ -3276,7 +3274,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ void CWidgetManager::startAnim( const std::string &animId ) { - CInterfaceAnim *pIT = parser->getAnim( animId ); + CInterfaceAnim *pIT = _Parser->getAnim( animId ); if( pIT == NULL ) return; @@ -3302,7 +3300,7 @@ namespace NLGUI // ------------------------------------------------------------------------------------------------ void CWidgetManager::stopAnim( const std::string &animId ) { - CInterfaceAnim *pIT = parser->getAnim( animId ); + CInterfaceAnim *pIT = _Parser->getAnim( animId ); for( uint i = 0; i < activeAnims.size(); ++i ) if( activeAnims[ i ] == pIT ) @@ -3325,7 +3323,7 @@ namespace NLGUI void CWidgetManager::runProcedure( const std::string &procName, CCtrlBase *pCaller, const std::vector< std::string> ¶mList ) { - CProcedure *procp = parser->getProc( procName ); + CProcedure *procp = _Parser->getProc( procName ); if( procp == NULL ) return; @@ -3361,7 +3359,7 @@ namespace NLGUI void CWidgetManager::setProcedureAction( const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms ) { - CProcedure *procp = parser->getProc( procName ); + CProcedure *procp = _Parser->getProc( procName ); if( procp == NULL ) return; @@ -3701,7 +3699,7 @@ namespace NLGUI CReflectableRegister::registerClasses(); - parser = IParser::createParser(); + _Parser = IParser::createParser(); _Pointer = NULL; curContextHelp = NULL; @@ -3743,6 +3741,9 @@ namespace NLGUI delete _MasterGroups[i].Group; } + delete _Parser; + _Parser = NULL; + _Pointer = NULL; curContextHelp = NULL;