diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-09 15:59:31 -0600 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-08-09 15:59:31 -0600 |
commit | 1c2f876c83afcb6dbbf830b3fe368eab86838552 (patch) | |
tree | 921c41b4b4d21ce3d08780dc424157dfa2e4fe96 /common | |
parent | a7c40cd33ba99658ac0c8849622a2b3f3db16de2 (diff) | |
download | sink-1c2f876c83afcb6dbbf830b3fe368eab86838552.tar.gz sink-1c2f876c83afcb6dbbf830b3fe368eab86838552.zip |
Avoid warning
setFuture can emit signals directly if the future is already stopped.
This does not apply to our case but it fixes the warning.
"QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"
Diffstat (limited to 'common')
-rw-r--r-- | common/asyncutils.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/common/asyncutils.h b/common/asyncutils.h index 67b5928..c80af30 100644 --- a/common/asyncutils.h +++ b/common/asyncutils.h | |||
@@ -31,12 +31,12 @@ KAsync::Job<T> run(const std::function<T()> &f, bool runAsync = true) | |||
31 | return KAsync::start<T>([f](KAsync::Future<T> &future) { | 31 | return KAsync::start<T>([f](KAsync::Future<T> &future) { |
32 | auto result = QtConcurrent::run(f); | 32 | auto result = QtConcurrent::run(f); |
33 | auto watcher = new QFutureWatcher<T>; | 33 | auto watcher = new QFutureWatcher<T>; |
34 | watcher->setFuture(result); | ||
35 | QObject::connect(watcher, &QFutureWatcher<T>::finished, watcher, [&future, watcher]() { | 34 | QObject::connect(watcher, &QFutureWatcher<T>::finished, watcher, [&future, watcher]() { |
36 | future.setValue(watcher->future().result()); | 35 | future.setValue(watcher->future().result()); |
37 | delete watcher; | 36 | delete watcher; |
38 | future.setFinished(); | 37 | future.setFinished(); |
39 | }); | 38 | }); |
39 | watcher->setFuture(result); | ||
40 | }); | 40 | }); |
41 | } else { | 41 | } else { |
42 | return KAsync::start<T>([f]() { | 42 | return KAsync::start<T>([f]() { |