De-inline QGenericRunnable overrides

Pins the vtable to a single TU and therefore prevents duplicate
vtables, -Wweak-vtables warnings and false-positive dynamic_casts.

This requires exporting QGenericRunnable, which hopefully won't
also export the nested class.

Task-number: QTBUG-45582
Change-Id: Ie1f29d25b0dcdee7654c33c497e8e0350d12e311
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit be1b589cb9f147762a5a73d2b3a44778b7ae7502)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-05-11 09:05:52 +02:00 committed by Qt Cherry-pick Bot
parent 07708f6e61
commit afe4666519
2 changed files with 15 additions and 9 deletions

View File

@ -21,6 +21,17 @@ QRunnable *QRunnable::warnNullCallable()
return nullptr; return nullptr;
} }
QRunnable::QGenericRunnable::~QGenericRunnable()
{
runHelper->destroy();
}
void QRunnable::QGenericRunnable::run()
{
runHelper->run();
}
/*! /*!
\class QRunnable \class QRunnable
\inmodule QtCore \inmodule QtCore

View File

@ -42,7 +42,7 @@ private:
class QGenericRunnable; class QGenericRunnable;
}; };
class QRunnable::QGenericRunnable : public QRunnable class Q_CORE_EXPORT QRunnable::QGenericRunnable : public QRunnable
{ {
// Type erasure, to only instantiate a non-virtual class per Callable: // Type erasure, to only instantiate a non-virtual class per Callable:
class HelperBase class HelperBase
@ -91,14 +91,9 @@ public:
: runHelper(new Helper<std::decay_t<Callable>>(std::forward<Callable>(c))) : runHelper(new Helper<std::decay_t<Callable>>(std::forward<Callable>(c)))
{ {
} }
~QGenericRunnable() override ~QGenericRunnable() override;
{
runHelper->destroy(); void run() override;
}
void run() override
{
runHelper->run();
}
}; };
namespace QtPrivate { namespace QtPrivate {