From afe4666519c57e7dd77248628bb71804d8670f05 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 11 May 2023 09:05:52 +0200 Subject: [PATCH] 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 Reviewed-by: Qt CI Bot (cherry picked from commit be1b589cb9f147762a5a73d2b3a44778b7ae7502) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/thread/qrunnable.cpp | 11 +++++++++++ src/corelib/thread/qrunnable.h | 13 ++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/corelib/thread/qrunnable.cpp b/src/corelib/thread/qrunnable.cpp index 5418fc8ecf9..bcb19d7af47 100644 --- a/src/corelib/thread/qrunnable.cpp +++ b/src/corelib/thread/qrunnable.cpp @@ -21,6 +21,17 @@ QRunnable *QRunnable::warnNullCallable() return nullptr; } + +QRunnable::QGenericRunnable::~QGenericRunnable() +{ + runHelper->destroy(); +} + +void QRunnable::QGenericRunnable::run() +{ + runHelper->run(); +} + /*! \class QRunnable \inmodule QtCore diff --git a/src/corelib/thread/qrunnable.h b/src/corelib/thread/qrunnable.h index 853228200fb..f0dd0a582ef 100644 --- a/src/corelib/thread/qrunnable.h +++ b/src/corelib/thread/qrunnable.h @@ -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::forward(c))) { } - ~QGenericRunnable() override - { - runHelper->destroy(); - } - void run() override - { - runHelper->run(); - } + ~QGenericRunnable() override; + + void run() override; }; namespace QtPrivate {