]> git.sesse.net Git - vlc/commitdiff
skins2: solve crashes due to releasing variables at termination
authorErwan Tulou <erwan10@videolan.org>
Tue, 23 Jun 2009 21:30:01 +0000 (23:30 +0200)
committerErwan Tulou <erwan10@videolan.org>
Tue, 23 Jun 2009 22:04:00 +0000 (00:04 +0200)
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.

modules/gui/skins2/src/var_manager.cpp

index 0dd18532170191202c40ca30909446f745c597cc..91f65fef838df636287dac75f2d1fa57ac186301 100644 (file)
@@ -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 );
 }