diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp index 068dc1af2a1..684593e16b8 100644 --- a/src/corelib/thread/qrunnable.cpp +++ b/src/corelib/thread/qrunnable.cpp @@ -9,6 +9,16 @@ QRunnable::~QRunnable() { } +/*! + \internal + Prints a warning and returns nullptr. +*/ +QRunnable *QRunnable::warnNullCallable() +{ + qWarning("Trying to create null QRunnable. This may stop working."); + return nullptr; +} + /*! \class QRunnable \inmodule QtCore diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h index 3b25b678363..37a99ea8413 100644 --- a/src/corelib/thread/qrunnable.h +++ b/src/corelib/thread/qrunnable.h @@ -5,7 +5,6 @@ #define QRUNNABLE_H #include -#include #include #include @@ -64,6 +63,9 @@ protected: { } }; + +private: + static Q_DECL_COLD_FUNCTION QRunnable *warnNullCallable(); }; class QGenericRunnable : public QRunnable @@ -105,10 +107,8 @@ QRunnable *QRunnable::create(Callable &&functionToRun) const void *functionPtr = reinterpret_cast(functionToRun); is_null = !functionPtr; } - if (is_null) { - qWarning() << "Trying to create null QRunnable. This may stop working."; - return nullptr; - } + if (is_null) + return warnNullCallable(); return new QGenericRunnable( new QGenericRunnableHelper>(