diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-12-03 07:11:31 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-12-03 07:11:31 +0100 |
commit | 0e8e2d5b103afa508f33c70904271e4fe72c870e (patch) | |
tree | 1a294a558aa6df6c83898cd2079b68ab57ffee05 /compat | |
parent | 2c80de4bf9ba4a7ee852540168c3de9bc9ec17d9 (diff) |
compat: add asserts
Diffstat (limited to 'compat')
-rw-r--r-- | compat/run-in-thread.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/compat/run-in-thread.hpp b/compat/run-in-thread.hpp index c32c232d..90aa143b 100644 --- a/compat/run-in-thread.hpp +++ b/compat/run-in-thread.hpp @@ -1,11 +1,15 @@ #pragma once -#include <QObject> +#include "ndebug-guard.hpp" +#include <cassert> #include <thread> #include <condition_variable> #include <utility> +#include <QObject> +#include <QThread> + namespace qt_impl_detail { template<typename t> @@ -50,7 +54,9 @@ auto run_in_thread_sync(QObject* obj, F&& fun) { QObject src; - src.moveToThread(obj->thread()); + QThread* t(obj->thread()); + assert(t); + src.moveToThread(t); QObject::connect(&src, &QObject::destroyed, obj, @@ -80,6 +86,8 @@ template<typename F> void run_in_thread_async(QObject* obj, F&& fun) { QObject src; - src.moveToThread(obj->thread()); + QThread* t(obj->thread()); + assert(t); + src.moveToThread(t); QObject::connect(&src, &QObject::destroyed, obj, std::move(fun), Qt::AutoConnection); } |