1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

Be safer when deleting playlist category items, this might fix some weirdness

This commit is contained in:
Leo Franchi
2011-08-02 23:28:03 -04:00
parent ae66fb8c5c
commit 5c58bc1d58

View File

@@ -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;
}
}