]> git.sesse.net Git - vlc/commitdiff
Skins2: Use typedefs for internal template-derived types, and rectify an accidental...
authorJP Dinger <jpd@videolan.org>
Sat, 12 Sep 2009 14:36:00 +0000 (16:36 +0200)
committerJP Dinger <jpd@videolan.org>
Sat, 5 Dec 2009 21:25:41 +0000 (22:25 +0100)
modules/gui/skins2/commands/async_queue.cpp
modules/gui/skins2/commands/async_queue.hpp
modules/gui/skins2/commands/cmd_muxer.cpp
modules/gui/skins2/commands/cmd_muxer.hpp

index bd7a071ec872d16a9820f539a9f0a4325adea65a..759ff6a6e5d37fa65d3ee7b67145aa3b6eb8f616 100644 (file)
@@ -89,22 +89,22 @@ void AsyncQueue::push( const CmdGenericPtr &rcCommand, bool removePrev )
 
 void AsyncQueue::remove( const string &rType, const CmdGenericPtr &rcCommand )
 {
-    list<CmdGenericPtr>::iterator it;
-    for( it = m_cmdList.begin(); it != m_cmdList.end(); it++ )
+    cmdList_t::iterator it;
+    for( it = m_cmdList.begin(); it != m_cmdList.end(); /* nothing */ )
     {
-        // Remove the command if it is of the given type
-        if( (*it).get()->getType() == rType )
+        // Remove the command if it is of the given type and the command
+        // doesn't disagree. Note trickery to avoid skipping entries
+        // while maintaining iterator validity.
+
+        if( (*it).get()->getType() == rType &&
+            rcCommand.get()->checkRemove( (*it).get() ) )
         {
-            // Maybe the command wants to check if it must really be
-            // removed
-            if( rcCommand.get()->checkRemove( (*it).get() ) == true )
-            {
-                list<CmdGenericPtr>::iterator itNew = it;
-                itNew++;
-                m_cmdList.erase( it );
-                it = itNew;
-            }
+            cmdList_t::iterator itNew = it;
+            ++itNew;
+            m_cmdList.erase( it );
+            it = itNew;
         }
+        else ++it;
     }
 }
 
index 626b21046f154b6f51031ff402fde2a7d2dddeef..2a89f117e03e2d0102449dfb491bfdf64ae153a8 100644 (file)
@@ -56,7 +56,8 @@ public:
 
 private:
     /// Command queue
-    list<CmdGenericPtr> m_cmdList;
+    typedef std::list<CmdGenericPtr> cmdList_t;
+    cmdList_t m_cmdList;
     /// Timer
     OSTimer *m_pTimer;
     /// Mutex
index 9b652ebe3c90dc50cea32a019d48053803bfa06b..9bc45c90ea1d9e1cc172a085079994bf7bae564f 100644 (file)
@@ -26,8 +26,8 @@
 
 void CmdMuxer::execute()
 {
-    list<CmdGeneric*>::const_iterator it;
-    for( it = m_list.begin(); it != m_list.end(); it++ )
+    cmdList_t::const_iterator it;
+    for( it = m_list.begin(); it != m_list.end(); ++it )
     {
         (*it)->execute();
     }
index 2ca6a9ce3574cbd5bb00cb62f8f178dfd5831a1b..c3b9dd682e8b5cd19c9e01ade1b3e35de667952a 100644 (file)
@@ -40,7 +40,8 @@ public:
 
 private:
     /// List of commands we will execute sequentially
-    list<CmdGeneric*> m_list;
+    typedef std::list<CmdGeneric*> cmdList_t;
+    cmdList_t m_list;
 };
 
 #endif