diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-08 22:46:00 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-12-08 22:46:00 +0100 |
commit | a860b011d7b12ae17d278d36a30eaa7754b7a2ce (patch) | |
tree | 92becfc44c7dca901255282433abb594bff50e2f /framework/src/domain/composercontroller.cpp | |
parent | e2520f1208a826f39e958908755efb2e39ee3950 (diff) | |
download | kube-a860b011d7b12ae17d278d36a30eaa7754b7a2ce.tar.gz kube-a860b011d7b12ae17d278d36a30eaa7754b7a2ce.zip |
Always guard async callbacks
Diffstat (limited to 'framework/src/domain/composercontroller.cpp')
-rw-r--r-- | framework/src/domain/composercontroller.cpp | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 471c30f8..e3218007 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp | |||
@@ -17,22 +17,16 @@ | |||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
18 | 02110-1301, USA. | 18 | 02110-1301, USA. |
19 | */ | 19 | */ |
20 | |||
21 | |||
22 | #include "composercontroller.h" | 20 | #include "composercontroller.h" |
23 | #include <settings/settings.h> | 21 | #include <settings/settings.h> |
24 | #include <KMime/Message> | 22 | #include <KMime/Message> |
25 | #include <QVariant> | 23 | #include <QVariant> |
26 | #include <QSortFilterProxyModel> | ||
27 | #include <QList> | 24 | #include <QList> |
28 | #include <QDebug> | 25 | #include <QDebug> |
29 | #include <QMimeDatabase> | 26 | #include <QMimeDatabase> |
30 | #include <QUrlQuery> | 27 | #include <QUrlQuery> |
31 | #include <QFileInfo> | 28 | #include <QFileInfo> |
32 | #include <QFile> | 29 | #include <QFile> |
33 | #include <QtConcurrent/QtConcurrentRun> | ||
34 | #include <QFuture> | ||
35 | #include <QFutureWatcher> | ||
36 | #include <sink/store.h> | 30 | #include <sink/store.h> |
37 | #include <sink/log.h> | 31 | #include <sink/log.h> |
38 | 32 | ||
@@ -40,6 +34,7 @@ | |||
40 | #include "recepientautocompletionmodel.h" | 34 | #include "recepientautocompletionmodel.h" |
41 | #include "mime/mailtemplates.h" | 35 | #include "mime/mailtemplates.h" |
42 | #include "mime/mailcrypto.h" | 36 | #include "mime/mailcrypto.h" |
37 | #include "async.h" | ||
43 | 38 | ||
44 | std::vector<GpgME::Key> &operator+=(std::vector<GpgME::Key> &list, const std::vector<GpgME::Key> &add) | 39 | std::vector<GpgME::Key> &operator+=(std::vector<GpgME::Key> &list, const std::vector<GpgME::Key> &add) |
45 | { | 40 | { |
@@ -97,21 +92,6 @@ public: | |||
97 | } | 92 | } |
98 | }; | 93 | }; |
99 | 94 | ||
100 | template<typename T> | ||
101 | void asyncRun(QObject *object, std::function<T()> run, std::function<void(T)> continuation) | ||
102 | { | ||
103 | auto guard = QPointer<QObject>{object}; | ||
104 | auto future = QtConcurrent::run(run); | ||
105 | auto watcher = new QFutureWatcher<T>; | ||
106 | QObject::connect(watcher, &QFutureWatcher<T>::finished, watcher, [watcher, continuation, guard]() { | ||
107 | if (guard) { | ||
108 | continuation(watcher->future().result()); | ||
109 | } | ||
110 | delete watcher; | ||
111 | }); | ||
112 | watcher->setFuture(future); | ||
113 | } | ||
114 | |||
115 | class AddresseeController : public Kube::ListPropertyController | 95 | class AddresseeController : public Kube::ListPropertyController |
116 | { | 96 | { |
117 | public: | 97 | public: |