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.

Pick-to: 6.6
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>
This commit is contained in:
Marc Mutz 2023-05-11 09:05:52 +02:00
parent 7a31911b79
commit be1b589cb9
2 changed files with 15 additions and 9 deletions

View File

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

View File

@ -42,7 +42,7 @@ private:
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:
class HelperBase
@ -91,14 +91,9 @@ public:
: runHelper(new Helper<std::decay_t<Callable>>(std::forward<Callable>(c)))
{
}
~QGenericRunnable() override
{
runHelper->destroy();
}
void run() override
{
runHelper->run();
}
~QGenericRunnable() override;
void run() override;
};
namespace QtPrivate {