summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-03-25 13:59:55 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-03-26 09:26:51 +0100
commite05d666d42dcda1fb97cec7039130ee118044c12 (patch)
tree411c598de4f9e1bc98a3db9dd71c1175f4a59fc1 /src
parent547228bf86281733c09a0638c57a4384c664f66e (diff)
QMetaType::id(): Fix ABI breakage
We cannot replace a non-inline method with an inline one without breaking the ABI. Instead, we now create a version with a dummy int parameter (to avoid ODR violations), and hide the non-inline version behind an ifdef, so that it is only visible in qmetatype.cpp. Pick-to: 6.1 Change-Id: Ib4e82e44071bdf5c37227409a56d377ff2e07ee0 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/CMakeLists.txt2
-rw-r--r--src/corelib/kernel/qmetatype.cpp14
-rw-r--r--src/corelib/kernel/qmetatype.h8
3 files changed, 23 insertions, 1 deletions
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index d8baa4952b..1a9a690f42 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -264,6 +264,8 @@ qt_internal_add_module(Core
# special case end
)
+qt_update_ignore_pch_source(Core kernel/qmetatype.cpp )
+
# special case begin
add_dependencies(Core qmodule_pri)
add_dependencies(Core ${QT_CMAKE_EXPORT_NAMESPACE}::moc)
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 60fe614922..9554a844f1 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -37,7 +37,9 @@
**
****************************************************************************/
+#define QT_QMETATYPE_BC_COMPAT 1
#include "qmetatype.h"
+#undef QT_QMETATYPE_BC_COMPAT
#include "qmetatype_p.h"
#include "qobjectdefs.h"
#include "qdatetime.h"
@@ -489,6 +491,18 @@ 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 fe68a15e5a..c08a87efd9 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -444,7 +444,12 @@ public:
bool isValid() const;
bool isRegistered() const;
- int id() const
+#if defined(QT_QMETATYPE_BC_COMPAT)
+ 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
{
if (d_ptr) {
if (int id = d_ptr->typeId.loadRelaxed())
@@ -453,6 +458,7 @@ public:
}
return 0;
};
+#endif
constexpr qsizetype sizeOf() const;
constexpr qsizetype alignOf() const;
constexpr TypeFlags flags() const;