Fixed: Respect coding standard for "parser" variable and delete it in destructor (fix a memory leak)

--HG--
branch : develop
This commit is contained in:
kervala 2016-12-04 16:52:50 +01:00
parent 13154bd79d
commit 8cc3963ddd
2 changed files with 11 additions and 10 deletions

View file

@ -502,7 +502,7 @@ namespace NLGUI
const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; } const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; }
IParser* getParser() const{ return parser; } IParser* getParser() const{ return _Parser; }
/// Retrieves the Id of the currently selected widgets /// Retrieves the Id of the currently selected widgets
void getEditorSelection( std::vector< std::string > &selection ); void getEditorSelection( std::vector< std::string > &selection );
@ -536,7 +536,7 @@ namespace NLGUI
CWidgetManager(); CWidgetManager();
~CWidgetManager(); ~CWidgetManager();
IParser *parser; IParser *_Parser;
static CWidgetManager *instance; static CWidgetManager *instance;
std::vector< SMasterGroup > _MasterGroups; std::vector< SMasterGroup > _MasterGroups;

View file

@ -466,7 +466,7 @@ namespace NLGUI
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
CInterfaceElement* CWidgetManager::getElementFromDefine( const std::string &defineId ) 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; bool handled = false;
CViewPointer *_Pointer = static_cast< CViewPointer* >( getPointer() );
if( evnt.getType() == CEventDescriptor::system ) if( evnt.getType() == CEventDescriptor::system )
{ {
handleSystemEvent( evnt ); handleSystemEvent( evnt );
@ -3276,7 +3274,7 @@ namespace NLGUI
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CWidgetManager::startAnim( const std::string &animId ) void CWidgetManager::startAnim( const std::string &animId )
{ {
CInterfaceAnim *pIT = parser->getAnim( animId ); CInterfaceAnim *pIT = _Parser->getAnim( animId );
if( pIT == NULL ) if( pIT == NULL )
return; return;
@ -3302,7 +3300,7 @@ namespace NLGUI
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CWidgetManager::stopAnim( const std::string &animId ) 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 ) for( uint i = 0; i < activeAnims.size(); ++i )
if( activeAnims[ i ] == pIT ) if( activeAnims[ i ] == pIT )
@ -3325,7 +3323,7 @@ namespace NLGUI
void CWidgetManager::runProcedure( const std::string &procName, CCtrlBase *pCaller, void CWidgetManager::runProcedure( const std::string &procName, CCtrlBase *pCaller,
const std::vector< std::string> &paramList ) const std::vector< std::string> &paramList )
{ {
CProcedure *procp = parser->getProc( procName ); CProcedure *procp = _Parser->getProc( procName );
if( procp == NULL ) if( procp == NULL )
return; return;
@ -3361,7 +3359,7 @@ namespace NLGUI
void CWidgetManager::setProcedureAction( const std::string &procName, uint actionIndex, void CWidgetManager::setProcedureAction( const std::string &procName, uint actionIndex,
const std::string &ah, const std::string &params ) const std::string &ah, const std::string &params )
{ {
CProcedure *procp = parser->getProc( procName ); CProcedure *procp = _Parser->getProc( procName );
if( procp == NULL ) if( procp == NULL )
return; return;
@ -3701,7 +3699,7 @@ namespace NLGUI
CReflectableRegister::registerClasses(); CReflectableRegister::registerClasses();
parser = IParser::createParser(); _Parser = IParser::createParser();
_Pointer = NULL; _Pointer = NULL;
curContextHelp = NULL; curContextHelp = NULL;
@ -3743,6 +3741,9 @@ namespace NLGUI
delete _MasterGroups[i].Group; delete _MasterGroups[i].Group;
} }
delete _Parser;
_Parser = NULL;
_Pointer = NULL; _Pointer = NULL;
curContextHelp = NULL; curContextHelp = NULL;