Commit 9ae1e54d authored by Scott Wheeler's avatar Scott Wheeler

Fix crash when you delete stuff using the RMB menu and then advance to

another track or stop.

svn path=/trunk/kdemultimedia/juk/; revision=205189
parent 6fc36057
......@@ -186,7 +186,8 @@ void Playlist::clearItems(const PlaylistItemList &items)
{
QPtrListIterator<PlaylistItem> it(items);
while(it.current()) {
// members.remove(it.current()->absFilePath()); // TODO: fix this for the new sorted class
emit(aboutToRemove(it.current()));
// members.remove(it.current()->absFilePath()); // TODO: fix this for the new sorted class
delete(it.current());
++it;
}
......@@ -238,8 +239,10 @@ void Playlist::remove(const PlaylistItemList &items)
if(KMessageBox::questionYesNoList(this, message, files) == KMessageBox::Yes) {
for(QPtrListIterator<PlaylistItem> it(items); it.current(); ++it) {
if(QFile::remove(it.current()->filePath()))
if(QFile::remove(it.current()->filePath())) {
emit(aboutToRemove(it.current()));
delete(it.current());
}
else
KMessageBox::sorry(this, i18n("Could not save delete ") + it.current()->fileName() + ".");
}
......
......@@ -164,6 +164,12 @@ signals:
void doubleClicked();
/**
* This signal is emitted just before a playlist item is removed from the
* list.
*/
void aboutToRemove(PlaylistItem *item);
private:
void setup();
QPtrStack<PlaylistItem> history;
......
......@@ -389,8 +389,6 @@ void PlaylistSplitter::removeSelectedItems()
{
PlaylistItemList items = playlistSelection();
checkPlayingItemBeforeRemove(items);
Playlist *p = visiblePlaylist();
if(p)
p->remove(items);
......@@ -399,8 +397,7 @@ void PlaylistSplitter::removeSelectedItems()
void PlaylistSplitter::clearSelectedItems()
{
PlaylistItemList items = playlistSelection();
checkPlayingItemBeforeRemove(items);
Playlist *p = visiblePlaylist();
if(p)
p->clearItems(items);
......@@ -539,6 +536,7 @@ void PlaylistSplitter::setupPlaylist(Playlist *p, bool raise, const char *icon)
connect(p, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
connect(p, SIGNAL(collectionChanged()), editor, SLOT(updateCollection()));
connect(p, SIGNAL(numberOfItemsChanged(Playlist *)), this, SLOT(playlistCountChanged(Playlist *)));
connect(p, SIGNAL(aboutToRemove(PlaylistItem *)), this, SLOT(playlistItemRemoved(PlaylistItem *)));
if(raise) {
playlistStack->raiseWidget(p);
......@@ -547,16 +545,6 @@ void PlaylistSplitter::setupPlaylist(Playlist *p, bool raise, const char *icon)
}
}
void PlaylistSplitter::checkPlayingItemBeforeRemove(PlaylistItemList &items)
{
PlaylistItem *item = items.first();
while(item) {
if(item == playingItem)
playingItem = 0;
item = items.next();
}
}
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////
......@@ -576,4 +564,10 @@ void PlaylistSplitter::playlistCountChanged(Playlist *p)
emit(selectedPlaylistCountChanged(p->childCount()));
}
void PlaylistSplitter::playlistItemRemoved(PlaylistItem *item)
{
if(item == playingItem)
playingItem = 0;
}
#include "playlistsplitter.moc"
......@@ -262,7 +262,7 @@ private:
void saveConfig();
void addImpl(const QString &file, Playlist *list);
void setupPlaylist(Playlist *p, bool raise = false, const char *icon = "midi");
void checkPlayingItemBeforeRemove(PlaylistItemList &items);
// void checkPlayingItemBeforeRemove(PlaylistItemList &items);
private slots:
void changePlaylist(PlaylistBoxItem *item);
......@@ -279,6 +279,11 @@ private slots:
*/
void queueDirectoryRemove(const QString &directory) { directoryQueueRemove.append(directory); }
/**
* This should be connected to Playlist::aboutToRemove()
*/
void playlistItemRemoved(PlaylistItem *item);
private:
PlaylistItem *playingItem;
PlaylistBox *playlistBox;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment