diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h index 67ce203458..d92eebae24 100644 --- a/src/corelib/thread/qrunnable.h +++ b/src/corelib/thread/qrunnable.h @@ -5,6 +5,7 @@ #define QRUNNABLE_H #include +#include #include #include @@ -54,14 +55,15 @@ protected: }; template - class QGenericRunnableHelper : public QGenericRunnableHelperBase + class QGenericRunnableHelper : public QGenericRunnableHelperBase, + private QtPrivate::CompactStorage { - Callable m_functionToRun; + using Storage = QtPrivate::CompactStorage; static void *impl(Op op, QGenericRunnableHelperBase *that, [[maybe_unused]] void *arg) { const auto _this = static_cast(that); switch (op) { - case Op::Run: _this->m_functionToRun(); break; + case Op::Run: _this->object()(); break; case Op::Destroy: delete _this; break; } return nullptr; @@ -70,7 +72,7 @@ protected: template explicit QGenericRunnableHelper(UniCallable &&functionToRun) noexcept : QGenericRunnableHelperBase(&impl), - m_functionToRun(std::forward(functionToRun)) + Storage{std::forward(functionToRun)} { } };