diff options
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 13 | ||||
-rw-r--r-- | tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 09f170c326..d3fa10ea4f 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -159,18 +159,19 @@ static void addQQmlMetaTypeInterfaces( QQmlMetaTypeData::CompositeMetaTypes &types = data->compositeMetaTypes[url]; if (types.type) { Q_ASSERT(types.listType); + + QMetaType::unregisterMetaType(QMetaType(types.type)); + QMetaType::unregisterMetaType(QMetaType(types.listType)); + types.type->name = std::move(ptr); types.type->QMetaTypeInterface::name = types.type->name.constData(); types.listType->name = std::move(lst); types.listType->QMetaTypeInterface::name = types.listType->name.constData(); - priv->typeId = QMetaType(types.type); - priv->listId = QMetaType(types.listType); - return; + } else { + types.type = new QQmlMetaTypeInterface(std::move(ptr)); + types.listType = new QQmlListMetaTypeInterface(std::move(lst), types.type); } - types.type = new QQmlMetaTypeInterface(std::move(ptr)); - types.listType = new QQmlListMetaTypeInterface(std::move(lst), types.type); - QMetaType ptr_type(types.type); QMetaType lst_type(types.listType); diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 5cf1e06ed5..c0fa508acf 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -884,6 +884,10 @@ void tst_qqmlmetatype::renameMetaType() // But the name is different QCOMPARE_NE(newTypeName, metaTypeName); + + // The QMetaType registry has been updated + QCOMPARE(QMetaType::fromName(newTypeName), metaType); + QVERIFY(!QMetaType::fromName(metaTypeName).isValid()); } } |