summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2020-04-23 09:44:13 +0200
committerDominik Holland <dominik.holland@qt.io>2020-04-27 09:13:42 +0200
commit570f23b4d0770bec522998241ecab4b7871334ae (patch)
tree69df0e80e6fa8a080b231d8d0f2ce3ddda4d837d /src
parent005f31781ac51b03f802d22006a1c3e11493ad5b (diff)
downloadqtivi-570f23b4d0770bec522998241ecab4b7871334ae.tar.gz
Fix qIviRegisterPendingReplyType to work with the new meta type system
This adds a workaround for QTBUG-83664 and makes sure we registering the correct name for the pending reply. Change-Id: I9d2c09b251820b4bc9b505704b549519da9c7a39 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/ivicore/qivipendingreply.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/ivicore/qivipendingreply.h b/src/ivicore/qivipendingreply.h
index 36368b8..e9bfc3d 100644
--- a/src/ivicore/qivipendingreply.h
+++ b/src/ivicore/qivipendingreply.h
@@ -48,6 +48,7 @@
#include <QSharedPointer>
#include <QVariant>
#include <QDebug>
+#include <QMetaEnum>
#include <QtIviCore/qtiviglobal.h>
@@ -266,7 +267,28 @@ public:
}
};
-template <typename T> void qIviRegisterPendingReplyType(const char *name = nullptr)
+//Workaround for QTBUG-83664
+//If T is a enum
+template <typename T> Q_INLINE_TEMPLATE typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, void>::Type qIviRegisterPendingReplyType(const char *name = nullptr)
+{
+ qRegisterMetaType<T>();
+ QString n;
+ if (name) {
+ n = QLatin1String(name);
+ } else {
+ QMetaEnum me = QMetaEnum::fromType<T>();
+ if (me.isValid() && me.isFlag())
+ n = QLatin1String(me.scope()) + QStringLiteral("::") + QLatin1String(me.name());
+ else
+ n = QLatin1String(QMetaType::typeName(qMetaTypeId<T>()));
+ }
+
+ const QString t_name = QStringLiteral("QIviPendingReply<") + n + QStringLiteral(">");
+ qRegisterMetaType<QIviPendingReplyBase>(qPrintable(t_name));
+}
+
+//If T is NOT a enum
+template <typename T> Q_INLINE_TEMPLATE typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, void>::Type qIviRegisterPendingReplyType(const char *name = nullptr)
{
qRegisterMetaType<T>();
const char* n = name ? name : QMetaType::typeName(qMetaTypeId<T>());