summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2022-09-19 12:23:04 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-09-21 18:41:43 +0000
commita8ccd9cd848be9aafd2d07d83a8897dc8b2a0cb3 (patch)
treefe62bde2ad27167971b8a6b974f4ee7322c5ae5a
parent0a4761522b9a3f74efc1abde032700368c47d40d (diff)
moc: Do not fail to compile meta-methods containing non-const ref types
Amends 2d0c31e7d92a3e9df4ce2b9c1d41b94fb12735fc. We were using MetaTypeDecay in qTryMetaTypeInterfaceForType; but that is not used by moc when complete types are enforced. Change qt_metaTypeArray to also use qTryMetaTypeInterfaceForType, so that the code path for "force complete types"[0] and the normal one do not diverge. [0] Most easily enabled by using one of the QML type registration macros. Fixes: QTBUG-106672 Pick-to: 6.4 6.4.0 Change-Id: I9bf14873d1d0c4127a676643f7e8eb77f6e42dc8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/kernel/qmetatype.h9
-rw-r--r--tests/auto/tools/moc/qmlmacro.h19
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp2
3 files changed, 29 insertions, 1 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index b119c20d2b..8e4a2af77b 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -2611,7 +2611,14 @@ constexpr const QMetaObject *QMetaType::metaObject() const
template<typename... T>
constexpr const QtPrivate::QMetaTypeInterface *const qt_metaTypeArray[] = {
- QtPrivate::qMetaTypeInterfaceForType<T>()...
+ /*
+ Unique in qTryMetaTypeInterfaceForType does not have to be unique here
+ as we require _all_ types here to be actually complete.
+ We just want to have the additional type processing that exist in
+ QtPrivate::qTryMetaTypeInterfaceForType as opposed to the normal
+ QtPrivate::qMetaTypeInterfaceForType used in QMetaType::fromType
+ */
+ QtPrivate::qTryMetaTypeInterfaceForType<void, QtPrivate::TypeAndForceComplete<T, std::true_type>>()...
};
constexpr const char *QMetaType::name() const
diff --git a/tests/auto/tools/moc/qmlmacro.h b/tests/auto/tools/moc/qmlmacro.h
new file mode 100644
index 0000000000..cb3b291bf1
--- /dev/null
+++ b/tests/auto/tools/moc/qmlmacro.h
@@ -0,0 +1,19 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+
+#ifndef QMlMACRO_H
+#define QMlMACRO_H
+
+#include <QObject>
+#include <QByteArray>
+
+struct QmlMacro : QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("QML.Element", "auto")
+
+ signals:
+ void f(QByteArray &b);
+};
+#endif
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 48249eec0c..2b4737bae3 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -56,6 +56,8 @@
#include "fwdclass2.h"
#include "fwdclass3.h"
+#include "qmlmacro.h"
+
#ifdef Q_MOC_RUN
// check that moc can parse these constructs, they are being used in Windows winsock2.h header
#define STRING_HASH_HASH(x) ("foo" ## x ## "bar")