diff options
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 10 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 16 | ||||
-rw-r--r-- | src/corelib/kernel/qobject_p.h | 6 | ||||
-rw-r--r-- | src/gui/text/qcssparser.cpp | 4 | ||||
-rw-r--r-- | src/gui/util/qshadergraphloader.cpp | 10 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo.cpp | 6 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 8 | ||||
-rw-r--r-- | src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 6 | ||||
-rw-r--r-- | src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 2 |
9 files changed, 34 insertions, 34 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 8d4d4d943f..e584fbba8e 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2309,24 +2309,24 @@ bool QMetaMethod::invoke(QObject *object, } QScopedPointer<QMetaCallEvent> event(new QMetaCallEvent(idx_offset, idx_relative, callFunction, nullptr, -1, paramCount)); - int *types = event->types(); + QMetaType *types = event->types(); void **args = event->args(); int argIndex = 0; for (int i = 1; i < paramCount; ++i) { - types[i] = QMetaType::fromName(typeNames[i]).id(); - if (types[i] == QMetaType::UnknownType && param[i]) { + types[i] = QMetaType::fromName(typeNames[i]); + if (!types[i].isValid() && param[i]) { // Try to register the type and try again before reporting an error. void *argv[] = { &types[i], &argIndex }; QMetaObject::metacall(object, QMetaObject::RegisterMethodArgumentMetaType, idx_relative + idx_offset, argv); - if (types[i] == -1) { + if (!types[i].isValid()) { qWarning("QMetaMethod::invoke: Unable to handle unregistered datatype '%s'", typeNames[i]); return false; } } - if (types[i] != QMetaType::UnknownType) { + if (types[i].isValid()) { args[i] = QMetaType(types[i]).create(param[i]); ++argIndex; } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index a84d501a32..1b8646947e 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -506,7 +506,7 @@ inline void QMetaCallEvent::allocArgs() if (!d.nargs_) return; - constexpr size_t each = sizeof(void*) + sizeof(int); + constexpr size_t each = sizeof(void*) + sizeof(QMetaType); void *const memory = d.nargs_ * each > sizeof(prealloc_) ? calloc(d.nargs_, each) : prealloc_; @@ -588,10 +588,10 @@ QMetaCallEvent::QMetaCallEvent(QtPrivate::QSlotObjectBase *slotO, QMetaCallEvent::~QMetaCallEvent() { if (d.nargs_) { - int *typeIDs = types(); + QMetaType *t = types(); for (int i = 0; i < d.nargs_; ++i) { - if (typeIDs[i] && d.args_[i]) - QMetaType(typeIDs[i]).destroy(d.args_[i]); + if (t[i].isValid() && d.args_[i]) + t[i].destroy(d.args_[i]); } if (reinterpret_cast<void*>(d.args_) != reinterpret_cast<void*>(prealloc_)) free(d.args_); @@ -3644,17 +3644,17 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect new QMetaCallEvent(c->method_offset, c->method_relative, c->callFunction, sender, signal, nargs); void **args = ev->args(); - int *types = ev->types(); + QMetaType *types = ev->types(); - types[0] = 0; // return type + types[0] = QMetaType(); // return type args[0] = nullptr; // return value if (nargs > 1) { for (int n = 1; n < nargs; ++n) - types[n] = argumentTypes[n-1]; + types[n] = QMetaType(argumentTypes[n-1]); for (int n = 1; n < nargs; ++n) - args[n] = QMetaType(types[n]).create(argv[n]); + args[n] = types[n].create(argv[n]); } locker.relock(); diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 2a5104c3dd..4a60d37191 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -548,8 +548,8 @@ public: inline int id() const { return d.method_offset_ + d.method_relative_; } inline const void * const* args() const { return d.args_; } inline void ** args() { return d.args_; } - inline const int *types() const { return reinterpret_cast<int*>(d.args_ + d.nargs_); } - inline int *types() { return reinterpret_cast<int*>(d.args_ + d.nargs_); } + inline const QMetaType *types() const { return reinterpret_cast<QMetaType *>(d.args_ + d.nargs_); } + inline QMetaType *types() { return reinterpret_cast<QMetaType *>(d.args_ + d.nargs_); } virtual void placeMetaCall(QObject *object) override; @@ -565,7 +565,7 @@ private: ushort method_relative_; } d; // preallocate enough space for three arguments - char prealloc_[3*(sizeof(void*) + sizeof(int))]; + alignas(void *) char prealloc_[3*sizeof(void*) + 3*sizeof(QMetaType)]; }; class QBoolBlocker diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index b57f933c37..86d3f77fee 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1139,14 +1139,14 @@ static bool setFontSizeFromValue(QCss::Value value, QFont *font, int *fontSizeAd if (s.endsWith(QLatin1String("pt"), Qt::CaseInsensitive)) { s.chop(2); value.variant = s; - if (value.variant.convert((QVariant::Type)qMetaTypeId<qreal>())) { + if (value.variant.convert(QMetaType::fromType<qreal>())) { font->setPointSizeF(value.variant.toReal()); valid = true; } } else if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) { s.chop(2); value.variant = s; - if (value.variant.convert(QMetaType::Int)) { + if (value.variant.convert(QMetaType::fromType<int>())) { font->setPixelSize(value.variant.toInt()); valid = true; } diff --git a/src/gui/util/qshadergraphloader.cpp b/src/gui/util/qshadergraphloader.cpp index 585becf47a..a938904651 100644 --- a/src/gui/util/qshadergraphloader.cpp +++ b/src/gui/util/qshadergraphloader.cpp @@ -187,21 +187,21 @@ void QShaderGraphLoader::load() if (parameterValue.isObject()) { const QJsonObject parameterObject = parameterValue.toObject(); const QString type = parameterObject.value(QStringLiteral("type")).toString(); - const int typeId = QMetaType::fromName(type.toUtf8()).id(); + const auto metaType = QMetaType::fromName(type.toUtf8()); const QString value = parameterObject.value(QStringLiteral("value")).toString(); auto variant = QVariant(value); - if (QMetaType(typeId).flags() & QMetaType::IsEnumeration) { - const QMetaObject *metaObject = QMetaType(typeId).metaObject(); + if (metaType.flags() & QMetaType::IsEnumeration) { + const QMetaObject *metaObject = metaType.metaObject(); const char *className = metaObject->className(); const QByteArray enumName = type.mid(static_cast<int>(qstrlen(className)) + 2).toUtf8(); const QMetaEnum metaEnum = metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); const int enumValue = metaEnum.keyToValue(value.toUtf8()); variant = QVariant(enumValue); - variant.convert(typeId); + variant.convert(metaType); } else { - variant.convert(typeId); + variant.convert(metaType); } node.setParameter(parameterName, variant); } else { diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index dff87217d4..f71c6d8509 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -159,11 +159,11 @@ void QHostInfoResult::postResultsReady(const QHostInfo &info) auto metaCallEvent = new QMetaCallEvent(slotObj, nullptr, signal_index, nargs); Q_CHECK_PTR(metaCallEvent); void **args = metaCallEvent->args(); - int *types = metaCallEvent->types(); + QMetaType *types = metaCallEvent->types(); auto voidType = QMetaType::fromType<void>(); auto hostInfoType = QMetaType::fromType<QHostInfo>(); - types[0] = voidType.id(); - types[1] = hostInfoType.id(); + types[0] = voidType; + types[1] = hostInfoType; args[0] = nullptr; args[1] = hostInfoType.create(&info); Q_CHECK_PTR(args[1]); diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 7754771332..cc43ca4490 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1016,7 +1016,7 @@ void Generator::generateMetacall() fprintf(out, " if (_id < %d)\n", int(methodList.size())); if (methodsWithAutomaticTypesHelper(methodList).isEmpty()) - fprintf(out, " *reinterpret_cast<int*>(_a[0]) = -1;\n"); + fprintf(out, " *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();\n"); else fprintf(out, " qt_static_metacall(this, _c, _id, _a);\n"); fprintf(out, " _id -= %d;\n }", int(methodList.size())); @@ -1177,13 +1177,13 @@ void Generator::generateStaticMetacall() if (!methodsWithAutomaticTypes.isEmpty()) { fprintf(out, " else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {\n"); fprintf(out, " switch (_id) {\n"); - fprintf(out, " default: *reinterpret_cast<int*>(_a[0]) = -1; break;\n"); + fprintf(out, " default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n"); QMap<int, QMultiMap<QByteArray, int> >::const_iterator it = methodsWithAutomaticTypes.constBegin(); const QMap<int, QMultiMap<QByteArray, int> >::const_iterator end = methodsWithAutomaticTypes.constEnd(); for ( ; it != end; ++it) { fprintf(out, " case %d:\n", it.key()); fprintf(out, " switch (*reinterpret_cast<int*>(_a[1])) {\n"); - fprintf(out, " default: *reinterpret_cast<int*>(_a[0]) = -1; break;\n"); + fprintf(out, " default: *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType(); break;\n"); auto jt = it->begin(); const auto jend = it->end(); while (jt != jend) { @@ -1191,7 +1191,7 @@ void Generator::generateStaticMetacall() const QByteArray &lastKey = jt.key(); ++jt; if (jt == jend || jt.key() != lastKey) - fprintf(out, " *reinterpret_cast<int*>(_a[0]) = qRegisterMetaType< %s >(); break;\n", lastKey.constData()); + fprintf(out, " *reinterpret_cast<QMetaType *>(_a[0]) = QMetaType::fromType< %s >(); break;\n", lastKey.constData()); } fprintf(out, " }\n"); fprintf(out, " break;\n"); diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index a99ac6a7c2..a8532f7003 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -104,7 +104,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) { isSignal ? "signal" : "method", mm.name.constData()); // check the return type first - int typeId = QMetaType::type(mm.normalizedType.constData()); + int typeId = QMetaType::fromName(mm.normalizedType).id(); if (typeId != QMetaType::Void) { if (typeId) { const char *typeName = QDBusMetaType::typeToSignature(typeId); @@ -158,7 +158,7 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) { // do we need to describe this argument? if (QDBusMetaType::signatureToType(signature) == QMetaType::UnknownType) { - const char *typeName = QMetaType::typeName(types.at(j)); + const char *typeName = QMetaType(types.at(j)).name(); xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n") .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) .arg(isOutput && !isSignal ? j - inputCount : j - 1) @@ -208,7 +208,7 @@ static QString generateInterfaceXml(const ClassDef *mo) if (!mp.write.isEmpty()) access |= 2; - int typeId = QMetaType::type(mp.type.constData()); + int typeId = QMetaType::fromName(mp.type).id(); if (!typeId) { fprintf(stderr, PROGRAMNAME ": unregistered type: '%s', ignoring\n", mp.type.constData()); diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index c7c08adb9b..48a0d91adb 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -246,7 +246,7 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection: return std::move(qttype).toLatin1(); } - return QVariant::typeToName(QVariant::Type(type)); + return QMetaType(type).name(); } static QString nonConstRefArg(const QByteArray &arg) |