Bug 250746 - 'Delete' key causing crash when deleting playlists [@ PlaylistBrowserNS::PlaylistBrowserView::keyPressEvent]
Summary: 'Delete' key causing crash when deleting playlists [@ PlaylistBrowserNS::Play...
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Playlists/Saved Playlists (show other bugs)
Version: 2.3.1-GIT
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: 2.4.0
Assignee: Amarok Developers
URL:
Keywords:
: 253629 258492 261764 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-09-10 09:27 UTC by James Duncan
Modified: 2011-12-07 15:48 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.4


Attachments
amarok debug output (13.56 KB, application/octet-stream)
2010-09-10 09:27 UTC, James Duncan
Details
KDE crash report (10.66 KB, application/octet-stream)
2010-09-10 09:28 UTC, James Duncan
Details
Patch for fixing the bug 250746 (1.78 KB, patch)
2010-11-19 21:06 UTC, Dennis
Details
New crash information added by DrKonqi (15.73 KB, text/plain)
2011-04-27 09:15 UTC, Andrew Wang
Details
New crash information added by DrKonqi (7.86 KB, text/plain)
2011-12-07 15:48 UTC, Mad Cyril
Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Duncan 2010-09-10 09:27:26 UTC
Created attachment 51502 [details]
amarok debug output

Version:           2.3.2-GIT (using KDE 4.4.2) 
OS:                Linux

Using the delete key to delete playlists consistently causes Amarok to crash on me.  Sometimes, after selecting a single playlist and pressing the delete key, the delete will execute properly without crashing, but this happens every time I use the delete key after selecting multiple playlists.  In addition, sometimes (five times so far for me) selecting multiple playlists under "Playlist Files on Disk" and pressing the delete key not only causes a crash, but also, somehow, results in one of my playlists under "Amarok Database" to be deleted.

Reproducible: Always

Steps to Reproduce:
1. Select multiple playlists
2. Press DEL (the delete key on the keyboard)

Actual Results:  
Crash (and possibly also losing one of the playlists listed under "Amarok Database").

Expected Results:  
The selected playlists are deleted and Amarok continues on its merry way (i.e., Amarok doesn't crash).

I've attached the end of the amarok debug output from the of the crashes, as well as the KDE crash report.
Comment 1 James Duncan 2010-09-10 09:28:20 UTC
Created attachment 51503 [details]
KDE crash report
Comment 2 Myriam Schweingruber 2010-09-10 15:07:39 UTC
Please always paste backtraces inline, else those are not searchable:


Thread 1 (Thread 0xb5280720 (LWP 8025)):
[KCrash Handler]
#6  0x01e172e4 in QSortFilterProxyModel::parent(QModelIndex const&) const () from /usr/lib/libQtGui.so.4
#7  0x00ada912 in QModelIndex::parent (this=0x923a860) at /usr/include/qt4/QtCore/qabstractitemmodel.h:389
#8  0x00df289e in PlaylistBrowserNS::PlaylistBrowserView::keyPressEvent (this=0x8c1cc80, event=0xbfb66c44) at /home/jtduncan/.src/amarok/src/browsers/playlistbrowser/PlaylistBrowserView.cpp:265
#9  0x01843503 in QWidget::event(QEvent*) () from /usr/lib/libQtGui.so.4
#10 0x01c3ffd3 in QFrame::event(QEvent*) () from /usr/lib/libQtGui.so.4
#11 0x01cdad97 in QAbstractScrollArea::event(QEvent*) () from /usr/lib/libQtGui.so.4
#12 0x01d8782c in QAbstractItemView::event(QEvent*) () from /usr/lib/libQtGui.so.4
#13 0x017e54dc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#14 0x017edb71 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#15 0x00444f2a in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#16 0x01434a3b in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
#17 0x017e62be in ?? () from /usr/lib/libQtGui.so.4
#18 0x0189fd90 in ?? () from /usr/lib/libQtGui.so.4
#19 0x018a22f5 in ?? () from /usr/lib/libQtGui.so.4
#20 0x01875757 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/libQtGui.so.4
#21 0x018a560a in ?? () from /usr/lib/libQtGui.so.4
#22 0x026b15e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#23 0x026b52d8 in ?? () from /lib/libglib-2.0.so.0
#24 0x026b54b8 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#25 0x014605d5 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#26 0x018a5135 in ?? () from /usr/lib/libQtGui.so.4
#27 0x01433059 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#28 0x014334aa in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#29 0x0143769f in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#30 0x017e5577 in QApplication::exec() () from /usr/lib/libQtGui.so.4
#31 0x08052822 in main (argc=3, argv=0xbfb67f04) at /home/jtduncan/.src/amarok/src/main.cpp:237
Comment 3 Mikko C. 2010-10-09 09:16:59 UTC
*** Bug 253629 has been marked as a duplicate of this bug. ***
Comment 4 Mikko C. 2010-10-09 09:17:36 UTC
confirmed by duplicate
Comment 5 Dennis 2010-11-19 21:06:25 UTC
Created attachment 53558 [details]
Patch for fixing the bug 250746

Hello, Here is a patch for fixing this bug. 

Summary:
I used actionsFor() method for getting the actions for the selected indexes(selected playlists) and then triggered the last action of the returned ActionList.

Things seems to work for me fine now.

I will also put this in the review-board.
Comment 6 Bart Cerneels 2010-11-21 11:50:57 UTC
commit 22c4f116fbb9ab10650884d181dbe4e25ae2221e
branch master
Author: Bart Cerneels <bart.cerneels@kde.org>
Date:   Sun Nov 21 11:46:59 2010 +0100

    Fix playlsit delete bugs.
    
    Using the playlist actions instead of removeRow().
    
    Patch by Dennis Francis.
    
    Removed the expandToDepth( 0 ) hack because comment #6 in BR 245646.
    
    BUG:250746
    BUG:250750

diff --git a/src/browsers/playlistbrowser/PlaylistBrowserView.cpp b/src/browsers/playlistbrowser/PlaylistBrowserView.cpp
index 2603e2f..45be175 100644
--- a/src/browsers/playlistbrowser/PlaylistBrowserView.cpp
+++ b/src/browsers/playlistbrowser/PlaylistBrowserView.cpp
@@ -263,8 +263,21 @@ PlaylistBrowserNS::PlaylistBrowserView::keyPressEvent( QKeyEvent *event )
     {
         case Qt::Key_Delete:
         {
-            foreach( const QModelIndex &selectedIdx, selectedIndexes() )
-                model()->removeRow( selectedIdx.row(), selectedIdx.parent() );
+            QModelIndexList indices = selectedIndexes();
+            QActionList actions = actionsFor( indices );
+
+            if( actions.isEmpty() )
+            {
+                debug() <<"No actions !";
+                return;
+            }
+            foreach( QAction *actn, actions )
+                if( actn )
+                    if( actn->objectName() == "deleteAction" )
+                    {
+                        actn->trigger();
+                        actn->setData( QVariant() );
+                    }
             return;
         }
      }
diff --git a/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp b/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
index ae61504..bf679fc 100644
--- a/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
+++ b/src/core-impl/podcasts/sql/SqlPodcastProvider.cpp
@@ -336,6 +336,7 @@ SqlPodcastProvider::playlistActions( Playlists::PlaylistPtr playlist )
     {
         actionChannels = m_removeAction->data().value<Podcasts::SqlPodcastChannelList>();
     }
+    m_removeAction->setObjectName( "deleteAction" );
 
     actionChannels << sqlChannel;
     m_removeAction->setData( QVariant::fromValue( actionChannels ) );
@@ -392,6 +393,7 @@ SqlPodcastProvider::trackActions( Playlists::PlaylistPtr playlist, int trackInde
         m_deleteAction->setProperty( "popupdropper_svg_id", "delete" );
         connect( m_deleteAction, SIGNAL( triggered() ), SLOT( slotDeleteDownloadedEpisodes() ) );
     }
+    m_deleteAction->setObjectName( "deleteAction" );
 
     if( m_writeTagsAction == 0 )
     {
diff --git a/src/playlistmanager/file/PlaylistFileProvider.cpp b/src/playlistmanager/file/PlaylistFileProvider.cpp
index 573cdff..22e8abe 100644
--- a/src/playlistmanager/file/PlaylistFileProvider.cpp
+++ b/src/playlistmanager/file/PlaylistFileProvider.cpp
@@ -138,6 +138,7 @@ PlaylistFileProvider::playlistActions( Playlists::PlaylistPtr playlist )
         m_deleteAction->setProperty( "popupdropper_svg_id", "delete" );
         connect( m_deleteAction, SIGNAL( triggered() ), SLOT( slotDelete() ) );
     }
+    m_deleteAction->setObjectName( "deleteAction" );
 
     Playlists::PlaylistFileList actionList =
             m_deleteAction->data().value<Playlists::PlaylistFileList>();
@@ -181,6 +182,7 @@ PlaylistFileProvider::trackActions( Playlists::PlaylistPtr playlist, int trackIn
                                              "Remove From \"%1\"", playlist->name() ) );
     }
 
+    m_removeTrackAction->setObjectName( "deleteAction" );
     //Add the playlist/track combination to a QMultiMap that is stored in the action.
     //In the slot we use this data to remove that track from the playlist.
     PlaylistTrackMap playlistMap = m_removeTrackAction->data().value<PlaylistTrackMap>();
diff --git a/src/playlistmanager/sql/SqlUserPlaylistProvider.cpp b/src/playlistmanager/sql/SqlUserPlaylistProvider.cpp
index 12da6ed..d2ae5b9 100644
--- a/src/playlistmanager/sql/SqlUserPlaylistProvider.cpp
+++ b/src/playlistmanager/sql/SqlUserPlaylistProvider.cpp
@@ -178,6 +178,7 @@ SqlUserPlaylistProvider::playlistActions( Playlists::PlaylistPtr playlist )
         m_deleteAction->setProperty( "popupdropper_svg_id", "delete" );
         connect( m_deleteAction, SIGNAL( triggered() ), SLOT( slotDelete() ) );
     }
+    m_deleteAction->setObjectName( "deleteAction" );
 
     Playlists::SqlPlaylistList actionList = m_deleteAction->data().value<Playlists::SqlPlaylistList>();
     actionList << sqlPlaylist;
@@ -204,6 +205,8 @@ SqlUserPlaylistProvider::trackActions( Playlists::PlaylistPtr playlist, int trac
         m_removeTrackAction->setProperty( "popupdropper_svg_id", "delete" );
         connect( m_removeTrackAction, SIGNAL( triggered() ), SLOT( slotRemove() ) );
     }
+    m_removeTrackAction->setObjectName( "deleteAction" );
+
     //Add the playlist/track combination to a QMultiMap that is stored in the action.
     //In the slot we use this data to remove that track from the playlist.
     PlaylistTrackMap playlistMap = m_removeTrackAction->data().value<PlaylistTrackMap>();
Comment 7 Myriam Schweingruber 2010-12-01 18:30:55 UTC
*** Bug 258492 has been marked as a duplicate of this bug. ***
Comment 8 Myriam Schweingruber 2011-01-04 04:33:38 UTC
*** Bug 261764 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Wang 2011-04-27 09:15:27 UTC
Created attachment 59351 [details]
New crash information added by DrKonqi

amarok (2.3.2) on KDE Platform 4.5.5 (KDE 4.5.5) using Qt 4.7.0

- What I was doing when the application crashed:

Selected multiple saved Amarok Database playlists and pressed the delete key, confirmed once, crash on second confirm. Upon restarting Amarok, only one playlist has been deleted.

-- Backtrace (Reduced):
#6  QModelIndex (this=0x2611e00, child=...) at ../../include/QtCore/../../src/corelib/kernel/qabstractitemmodel.h:65
#7  QSortFilterProxyModel::parent (this=0x2611e00, child=...) at itemviews/qsortfilterproxymodel.cpp:1656
#8  0x00007f501b98200f in parent (this=0x26120f0, event=<value optimized out>) at /usr/include/qt4/QtCore/qabstractitemmodel.h:389
#9  PlaylistBrowserNS::PlaylistBrowserView::keyPressEvent (this=0x26120f0, event=<value optimized out>) at ../../src/browsers/playlistbrowser/PlaylistBrowserView.cpp:265
#10 0x00007f501a9cccfa in QWidget::event (this=0x26120f0, event=0x7fff41f0e830) at kernel/qwidget.cpp:8222
Comment 10 Mad Cyril 2011-12-07 15:48:47 UTC
Created attachment 66482 [details]
New crash information added by DrKonqi

crash on selecting multiple playlists to delete