From f53c2885bff3408bf6aa8d89a9cb913980f51e9b Mon Sep 17 00:00:00 2001 From: Damien Caliste Date: Mon, 14 Sep 2020 11:29:54 +0200 Subject: Adjust to Qt6 QMetaType API changes Change-Id: I154b232699932a5c721cb7cff4476f20ac196cad Reviewed-by: Christopher Adams Reviewed-by: David Llewellyn-Jones --- src/libraries/qmfclient/qmailstore_p.cpp | 4 ++-- src/libraries/qmfclient/support/qcopadaptor.cpp | 14 +++++--------- src/libraries/qmfclient/support/qmailipc.h | 8 ++------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/libraries/qmfclient/qmailstore_p.cpp b/src/libraries/qmfclient/qmailstore_p.cpp index 9344f19b..4495b8ad 100644 --- a/src/libraries/qmfclient/qmailstore_p.cpp +++ b/src/libraries/qmfclient/qmailstore_p.cpp @@ -2859,7 +2859,7 @@ static QString queryText(const QString &query, const QList &values) int index = result.indexOf(marker); while ((index != -1) && (it != end)) { QString substitute((*it).toString()); - if ((*it).type() == QVariant::String) + if ((*it).metaType() == QMetaType::fromType()) substitute.prepend(quote).append(quote); result.replace(index, 1, substitute); @@ -2874,7 +2874,7 @@ static QString queryText(const QString &query, const QList &values) static QString queryText(const QSqlQuery &query) { // Note: we currently only handle positional parameters - return queryText(query.lastQuery().simplified(), query.boundValues().values()); + return queryText(query.lastQuery().simplified(), query.boundValues()); } QSqlQuery QMailStorePrivate::prepare(const QString& sql) diff --git a/src/libraries/qmfclient/support/qcopadaptor.cpp b/src/libraries/qmfclient/support/qcopadaptor.cpp index a8f84c75..90d07eac 100644 --- a/src/libraries/qmfclient/support/qcopadaptor.cpp +++ b/src/libraries/qmfclient/support/qcopadaptor.cpp @@ -193,17 +193,13 @@ QCopAdaptorPrivate::~QCopAdaptorPrivate() // Get the QVariant type number for a type name. int QCopAdaptorPrivate::typeFromName( const QByteArray& type ) { - int id; if (type.endsWith('*')) return QMetaType::VoidStar; else if ( type.size() == 0 || type == "void" ) return QMetaType::Void; else if ( type == "QVariant" ) return QCopAdaptorPrivate::QVariantId; - id = QMetaType::type( type.constData() ); - if ( id != (int)QMetaType::Void ) - return id; - return QVariant::nameToType(type); + return QMetaType::fromName(type).id(); } // Returns the connection types associated with a signal or slot member. @@ -260,7 +256,7 @@ int QCopAdaptorPrivate::qt_metacall(QMetaObject::Call c, int id, void **a) QList args; for (int i = 0; i < info->numArgs; ++i) { if (info->types[i] != QCopAdaptorPrivate::QVariantId) { - QVariant arg(info->types[i], a[i + 1]); + QVariant arg(QMetaType(info->types[i]), a[i + 1]); args.append(arg); } else { args.append(*((const QVariant *)(a[i + 1]))); @@ -295,12 +291,12 @@ public: clear(); create(typeOrMetaType, 0); d.is_null = false; - QMetaType::load(stream, d.type, const_cast(constData())); + d.type().load(stream, const_cast(constData())); } void save(QDataStream& stream) const { - QMetaType::save(stream, d.type, constData()); + d.type().save(stream, constData()); } }; @@ -610,7 +606,7 @@ void QCopAdaptor::received(const QString& msg, const QByteArray& data) QVariant returnValue; QVarLengthArray a(info->numArgs + 1); if (info->returnType != (int)QVariant::Invalid && info->returnType != (int)QMetaType::Void) { - returnValue = QVariant(info->returnType, (const void *)0); + returnValue = QVariant(QMetaType(info->returnType), (const void *)0); a[0] = returnValue.data(); } else { a[0] = 0; diff --git a/src/libraries/qmfclient/support/qmailipc.h b/src/libraries/qmfclient/support/qmailipc.h index 00a8f963..0f9f2dd5 100644 --- a/src/libraries/qmfclient/support/qmailipc.h +++ b/src/libraries/qmfclient/support/qmailipc.h @@ -57,12 +57,9 @@ struct QMetaTypeRegister template<> \ struct QMetaTypeRegister< TYPE > \ { \ - static int registerType() \ - { \ + static int registerType() { \ _QATOMIC_ONCE(); \ - int id = qMetaTypeId(); \ - if ( id >= static_cast(QMetaType::User) ) \ - qRegisterMetaTypeStreamOperators< TYPE >( #TYPE ); \ + qRegisterMetaType( #TYPE ); \ return 1; \ } \ static int __init_variable__; \ @@ -83,7 +80,6 @@ struct QMetaTypeRegister static int registerType() { \ _QATOMIC_ONCE(); \ qRegisterMetaType< TYPE >( #TYPE ); \ - qRegisterMetaTypeStreamOperators< TYPE >( #TYPE ); \ return 1; \ } \ static int __init_variable__; \ -- cgit v1.2.3