From 2d61fe6c876c87ad77bb2e65ce8fd4c24445f4b6 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Fri, 27 Nov 2015 12:03:47 +0000 Subject: [PATCH] Changed my mind about automatically passing QFutures. --- ext/libclementine-common/core/closure.h | 10 ---------- src/engines/gstengine.cpp | 9 ++++++--- src/globalsearch/searchprovider.cpp | 3 ++- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/ext/libclementine-common/core/closure.h b/ext/libclementine-common/core/closure.h index d8734ab90..56be823e0 100644 --- a/ext/libclementine-common/core/closure.h +++ b/ext/libclementine-common/core/closure.h @@ -197,16 +197,6 @@ _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...); -} - -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...); } diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 17f14af5e..51d2c5e50 100644 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -455,8 +455,9 @@ bool GstEngine::Play(quint64 offset_nanosec) { QFuture future = current_pipeline_->SetState(GST_STATE_PLAYING); - NewClosure(future, this, SLOT(PlayDone(QFuture, quint64, int)), offset_nanosec, - current_pipeline_->id()); + NewClosure(future, this, + SLOT(PlayDone(QFuture, quint64, int)), + future, offset_nanosec, current_pipeline_->id()); if (is_fading_out_to_pause_) { current_pipeline_->SetState(GST_STATE_PAUSED); @@ -848,7 +849,9 @@ int GstEngine::AddBackgroundStream(shared_ptr pipeline) { background_streams_[stream_id] = pipeline; QFuture future = pipeline->SetState(GST_STATE_PLAYING); - NewClosure(future, this, SLOT(BackgroundStreamPlayDone(QFuture, int)), stream_id); + NewClosure(future, this, + SLOT(BackgroundStreamPlayDone(QFuture, int)), + future, stream_id); return stream_id; } diff --git a/src/globalsearch/searchprovider.cpp b/src/globalsearch/searchprovider.cpp index 6a95f861e..b60ee2c34 100644 --- a/src/globalsearch/searchprovider.cpp +++ b/src/globalsearch/searchprovider.cpp @@ -82,7 +82,8 @@ void BlockingSearchProvider::SearchAsync(int id, const QString& query) { QFuture future = QtConcurrent::run(this, &BlockingSearchProvider::Search, id, query); NewClosure(future, this, - SLOT(BlockingSearchFinished(QFuture, int)), id); + SLOT(BlockingSearchFinished(QFuture, int)), future, + id); } void BlockingSearchProvider::BlockingSearchFinished(QFuture future,