[vlc-devel] commit: skins2: solve crashes due to releasing variables at termination ( Erwan Tulou )

git version control git at videolan.org
Wed Jun 24 00:11:16 CEST 2009


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Jun 23 23:30:01 2009 +0200| [fb771cf9b235d5c64030236e63ca4585db840efe] | committer: 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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fb771cf9b235d5c64030236e63ca4585db840efe
---

 modules/gui/skins2/src/var_manager.cpp |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/modules/gui/skins2/src/var_manager.cpp b/modules/gui/skins2/src/var_manager.cpp
index 0dd1853..91f65fe 100644
--- a/modules/gui/skins2/src/var_manager.cpp
+++ b/modules/gui/skins2/src/var_manager.cpp
@@ -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 );
 }
 
 




More information about the vlc-devel mailing list