From 5c58bc1d584081b35a754d4181ad4ff2f8193b15 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Tue, 2 Aug 2011 23:28:03 -0400 Subject: [PATCH] Be safer when deleting playlist category items, this might fix some weirdness --- src/sourcetree/items/collectionitem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sourcetree/items/collectionitem.cpp b/src/sourcetree/items/collectionitem.cpp index 0a886bafc..1138259bb 100644 --- a/src/sourcetree/items/collectionitem.cpp +++ b/src/sourcetree/items/collectionitem.cpp @@ -193,7 +193,8 @@ CollectionItem::playlistDeletedInternal( SourceTreeItem* parent, const T& p ) } } - if( parent->children().isEmpty() && parent->parent() ) // Don't leave an empty Playlist or Station category + if( ( parent == m_playlists || parent == m_stations ) && + parent->children().isEmpty() && parent->parent() ) // Don't leave an empty Playlist or Station category { int idx = parent->parent()->children().indexOf( parent ); if( idx < 0 ) @@ -202,6 +203,12 @@ CollectionItem::playlistDeletedInternal( SourceTreeItem* parent, const T& p ) parent->parent()->beginRowsRemoved( idx, idx ); parent->parent()->removeChild( parent ); parent->parent()->endRowsRemoved(); + + if( parent == m_playlists ) + m_playlists = 0; + else if( parent == m_stations ) + m_stations = 0; + delete parent; } }