Bugfix amarok crash

Ralf Engels ralf-engels at gmx.de
Fri Aug 13 21:28:32 CEST 2010


Hi all,
the following change seems to fix the Amarok crashes for me.
Surprisingly.

I also have a branch with three other low hanging fruits on gitorious.
You could just cherry-pick the changes...
http://gitorious.org/~rengels/amarok/rengelss-amarok/commits/removetrack


Here is the fix:


Commit 83b5e55cc41d847ac042e8be5fa0af899ff78015
Author: Ralf Engels <ralf.engels at nokia.com>
Date:   Fri Aug 13 16:21:46 2010 +0200

    Seems to fix Amarok crashes

diff --git a/src/playlist/PlaylistModel.cpp
b/src/playlist/PlaylistModel.cpp
index 56ea1c0..f462dbf 100644
--- a/src/playlist/PlaylistModel.cpp
+++ b/src/playlist/PlaylistModel.cpp
@@ -777,13 +777,9 @@ Playlist::Model::removeTracksCommand( const
RemoveCmdList& cmds )
     foreach( const RemoveCmd &rc, cmds )
     {
         Meta::TrackPtr track = rc.first;
-        m_totalLength -= track->length();
-        m_totalSize -= track->filesize();
-        unsubscribeFrom( track );
-        if ( track->album() )
-            unsubscribeFrom( track->album() );
-
         Item* item = originalList.at(rc.second);
+        Q_ASSERT( track == item->track() );
+
         int idx = rowForItem( item );
         if (idx != -1) {
             beginRemoveRows(QModelIndex(), idx, idx);
@@ -794,6 +790,16 @@ Playlist::Model::removeTracksCommand( const
RemoveCmdList& cmds )
         } else {
             error() << "tried to delete a non-existent item:" <<
rc.first->prettyName() << rc.second;
         }
+
+        m_totalLength -= track->length();
+        m_totalSize -= track->filesize();
+
+        if( !containsTrack( track ) ) // check against same track two
times in playlist
+        {
+            unsubscribeFrom( track );
+            if ( track->album() )
+                unsubscribeFrom( track->album() );
+        }
     }
 
     qDeleteAll(delitems);




More information about the Amarok-devel mailing list