diff options
-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); } |