mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Don't crash when closing a playlist that has a pending SongLoaderInserter. Fixes issue #1471
This commit is contained in:
parent
8e70124830
commit
0acfbda94d
@ -666,7 +666,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, int ro
|
||||
}
|
||||
|
||||
void Playlist::InsertUrls(const QList<QUrl> &urls, int pos, bool play_now, bool enqueue) {
|
||||
SongLoaderInserter* inserter = new SongLoaderInserter(task_manager_, library_, this);
|
||||
SongLoaderInserter* inserter = new SongLoaderInserter(task_manager_, library_);
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(LoadTracksError(QString)));
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, urls);
|
||||
|
@ -21,9 +21,8 @@
|
||||
#include "core/taskmanager.h"
|
||||
|
||||
SongLoaderInserter::SongLoaderInserter(
|
||||
TaskManager* task_manager, LibraryBackendInterface* library, QObject *parent)
|
||||
: QObject(parent),
|
||||
task_manager_(task_manager),
|
||||
TaskManager* task_manager, LibraryBackendInterface* library)
|
||||
: task_manager_(task_manager),
|
||||
destination_(NULL),
|
||||
row_(-1),
|
||||
play_now_(true),
|
||||
@ -44,6 +43,8 @@ void SongLoaderInserter::Load(Playlist *destination,
|
||||
row_ = row;
|
||||
play_now_ = play_now;
|
||||
|
||||
connect(destination, SIGNAL(destroyed()), SLOT(DestinationDestroyed()));
|
||||
|
||||
foreach (const QUrl& url, urls) {
|
||||
SongLoader* loader = new SongLoader(library_, this);
|
||||
SongLoader::Result ret = loader->Load(url);
|
||||
@ -70,6 +71,10 @@ void SongLoaderInserter::Load(Playlist *destination,
|
||||
}
|
||||
}
|
||||
|
||||
void SongLoaderInserter::DestinationDestroyed() {
|
||||
destination_ = NULL;
|
||||
}
|
||||
|
||||
void SongLoaderInserter::PendingLoadFinished(bool success) {
|
||||
SongLoader* loader = qobject_cast<SongLoader*>(sender());
|
||||
if (!loader || !pending_.contains(loader))
|
||||
@ -91,7 +96,9 @@ void SongLoaderInserter::PendingLoadFinished(bool success) {
|
||||
}
|
||||
|
||||
void SongLoaderInserter::Finished() {
|
||||
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_);
|
||||
if (destination_) {
|
||||
destination_->InsertSongsOrLibraryItems(songs_, row_, play_now_, enqueue_);
|
||||
}
|
||||
|
||||
deleteLater();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class QModelIndex;
|
||||
class SongLoaderInserter : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SongLoaderInserter(TaskManager* task_manager, LibraryBackendInterface* library, QObject* parent = 0);
|
||||
SongLoaderInserter(TaskManager* task_manager, LibraryBackendInterface* library);
|
||||
~SongLoaderInserter();
|
||||
|
||||
void Load(Playlist* destination, int row, bool play_now, bool enqueue,
|
||||
@ -45,6 +45,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void PendingLoadFinished(bool success);
|
||||
void DestinationDestroyed();
|
||||
|
||||
private:
|
||||
void Finished();
|
||||
|
@ -53,7 +53,6 @@
|
||||
#include "playlist/playlistview.h"
|
||||
#include "playlist/queue.h"
|
||||
#include "playlist/queuemanager.h"
|
||||
#include "playlist/songloaderinserter.h"
|
||||
#include "playlist/songplaylistitem.h"
|
||||
#include "playlistparsers/playlistparser.h"
|
||||
#include "radio/magnatuneservice.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user