diff --git a/ext/libclementine-common/core/closure.h b/ext/libclementine-common/core/closure.h index b9e7e06ad..2f43a9dd6 100644 --- a/ext/libclementine-common/core/closure.h +++ b/ext/libclementine-common/core/closure.h @@ -197,8 +197,17 @@ _detail::ClosureBase* NewClosure(QFuture future, QObject* receiver, QFutureWatcher* watcher = new QFutureWatcher; watcher->setFuture(future); QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater())); - return NewClosure(watcher, SIGNAL(finished()), - receiver, slot, future, args...); + return NewClosure(watcher, SIGNAL(finished()), receiver, slot, future, + args...); +} + +template +_detail::ClosureBase* NewClosure(QFuture future, QObject* receiver, + const char* slot, const Args&... args) { + QFutureWatcher* watcher = new QFutureWatcher; + watcher->setFuture(future); + QObject::connect(watcher, SIGNAL(finished()), watcher, SLOT(deleteLater())); + return NewClosure(watcher, SIGNAL(finished()), receiver, slot, args...); } void DoAfter(QObject* receiver, const char* slot, int msec); diff --git a/src/core/modelfuturewatcher.h b/src/core/modelfuturewatcher.h deleted file mode 100644 index 7bca790d2..000000000 --- a/src/core/modelfuturewatcher.h +++ /dev/null @@ -1,39 +0,0 @@ -/* This file is part of Clementine. - Copyright 2010, 2014, John Maguire - Copyright 2014, Krzysztof Sobiecki - - Clementine is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Clementine is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Clementine. If not, see . -*/ - -#ifndef CORE_MODELFUTUREWATCHER_H_ -#define CORE_MODELFUTUREWATCHER_H_ - -#include -#include - -template -class ModelFutureWatcher : public QFutureWatcher { - public: - explicit ModelFutureWatcher(const QModelIndex& index, QObject* parent = nullptr) - : QFutureWatcher(parent), index_(index) {} - - ~ModelFutureWatcher() {} - - const QPersistentModelIndex& index() const { return index_; } - - private: - QPersistentModelIndex index_; -}; - -#endif // CORE_MODELFUTUREWATCHER_H_ diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 3e74a08b8..ff3dd456a 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -47,7 +47,6 @@ #include "core/application.h" #include "core/closure.h" #include "core/logging.h" -#include "core/modelfuturewatcher.h" #include "core/qhash_qurl.h" #include "core/tagreaderclient.h" #include "core/timeconstants.h" @@ -417,20 +416,13 @@ void Playlist::SongSaveComplete(TagReaderReply* reply, const QPersistentModelIndex& index) { if (reply->is_successful() && index.isValid()) { QFuture future = item_at(index.row())->BackgroundReload(); - ModelFutureWatcher* watcher = - new ModelFutureWatcher(index, this); - watcher->setFuture(future); - connect(watcher, SIGNAL(finished()), SLOT(ItemReloadComplete())); + NewClosure(future, this, SLOT(ItemReloadComplete(QPersistentModelIndex)), + index); } - reply->deleteLater(); } -void Playlist::ItemReloadComplete() { - ModelFutureWatcher* watcher = - static_cast*>(sender()); - watcher->deleteLater(); - const QPersistentModelIndex& index = watcher->index(); +void Playlist::ItemReloadComplete(const QPersistentModelIndex& index) { if (index.isValid()) { emit dataChanged(index, index); emit EditingFinished(index); diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 8b9328804..8204e7f60 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -393,7 +393,7 @@ signals: void QueueLayoutChanged(); void SongSaveComplete(TagReaderReply* reply, const QPersistentModelIndex& index); - void ItemReloadComplete(); + void ItemReloadComplete(const QPersistentModelIndex& index); void ItemsLoaded(); void SongInsertVetoListenerDestroyed(); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 26857966b..6bf2b08e7 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -53,7 +53,6 @@ #include "core/mac_startup.h" #include "core/mergedproxymodel.h" #include "core/mimedata.h" -#include "core/modelfuturewatcher.h" #include "core/mpris_common.h" #include "core/network.h" #include "core/player.h"