From d5c605b14896a444430414a7dc719397107cdc9d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 6 Dec 2021 13:30:10 +0100 Subject: QMetaType: port the BC fix for id() to new QT_REMOVED_SINCE The allows qmetatype.cpp compilation to enjoy PCH again. Change-Id: I47c5af33a5dbc930ee4c120b254e732c52bc2369 Reviewed-by: Fabian Kosmale --- src/corelib/CMakeLists.txt | 1 - src/corelib/compat/removed_api.cpp | 17 +++++++++++++++++ src/corelib/kernel/qmetatype.cpp | 14 -------------- src/corelib/kernel/qmetatype.h | 3 ++- 4 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index cd79a9f0c2..e02f79b8f0 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -279,7 +279,6 @@ qt_internal_add_module(Core set(corelib_no_pch_sources compat/removed_api.cpp - kernel/qmetatype.cpp ) foreach(src ${corelib_no_pch_sources}) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 8d5bfb44a7..566c7b608b 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -43,6 +43,23 @@ QT_USE_NAMESPACE +#if QT_REMOVED_SINCE(6, 1) + +#include "qmetatype.h" + +// keep in sync with version in header +int QMetaType::id() const +{ + if (d_ptr) { + if (int id = d_ptr->typeId.loadRelaxed()) + return id; + return idHelper(); + } + return 0; +} + +#endif // QT_REMOVED_SINCE(6, 1) + #if QT_REMOVED_SINCE(6, 3) #include "tools/qcryptographichash.h" diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index cb45031c9a..9494ff84f9 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -37,9 +37,7 @@ ** ****************************************************************************/ -#define QT_QMETATYPE_BC_COMPAT 1 #include "qmetatype.h" -#undef QT_QMETATYPE_BC_COMPAT #include "qmetatype_p.h" #include "qobjectdefs.h" #include "qdatetime.h" @@ -491,18 +489,6 @@ bool QMetaType::isRegistered() const Returns id type hold by this QMetatype instance. */ -// keep in sync with version in header -// ### Qt 7::remove BC helper -int QMetaType::id() const -{ - if (d_ptr) { - if (int id = d_ptr->typeId.loadRelaxed()) - return id; - return idHelper(); - } - return 0; -} - /*! \internal The slowpath of id(). Precondition: d_ptr != nullptr diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 575b6bec5e..674404b143 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -445,13 +445,14 @@ public: bool isValid() const; bool isRegistered() const; -#if defined(QT_QMETATYPE_BC_COMPAT) || defined(Q_QDOC) +#if QT_REMOVED_SINCE(6, 1) || defined(Q_QDOC) int id() const; #else // ### Qt 7: Remove traces of out of line version // unused int parameter is used to avoid ODR violation int id(int = 0) const { + // keep in sync with the version in removed_api.cpp if (d_ptr) { if (int id = d_ptr->typeId.loadRelaxed()) return id; -- cgit v1.2.3