Commit fb771cf9 authored by Erwan Tulou's avatar Erwan Tulou

skins2: solve crashes due to releasing variables at termination

skins was using two lists of variables (named and anonymous).
The problem was that variables from one list held references to variables from the other list and vice-versa. Whatever the order of releasing them, crashes could occur.

This patch uses the anonymous list to keep a reference on **all** variables.
This guarantees they are released in the reverse order from creation.
parent c0d7a7d3
......@@ -35,12 +35,6 @@ VarManager::VarManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
VarManager::~VarManager()
{
// Delete the anonymous variables
while( !m_anonVarList.empty() )
{
m_anonVarList.pop_back();
}
// Delete the variables in the reverse order they were added
list<string>::const_iterator it1;
for( it1 = m_varList.begin(); it1 != m_varList.end(); it1++ )
......@@ -48,6 +42,13 @@ VarManager::~VarManager()
m_varMap.erase(*it1);
}
// Delete the anonymous variables
while( !m_anonVarList.empty() )
{
m_anonVarList.pop_back();
}
delete m_pTooltipText;
// Warning! the help text must be the last variable to be deleted,
......@@ -85,6 +86,8 @@ void VarManager::registerVar( const VariablePtr &rcVar, const string &rName )
{
m_varMap[rName] = rcVar;
m_varList.push_front( rName );
m_anonVarList.push_back( rcVar );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment