Commit cb86cc3b authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Thomas Hartmann

QmlDesigner: Only register mockup object if not available

If a cpp type is somehow available do not create the mockup.

Change-Id: Ibd76429c3d1190c46a223062d77d676f728fe666
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 148e5a27
......@@ -685,16 +685,36 @@ void NodeInstanceServer::setupDummysForContext(QQmlContext *context)
}
}
static bool isTypeAvailable(const MockupTypeContainer &mockupType, QQmlEngine *engine)
{
QString qmlSource;
qmlSource.append("import " +
mockupType.importUri()
+ " "
+ QString::number(mockupType.majorVersion())
+ "." + QString::number(mockupType.minorVersion())
+ "\n");
qmlSource.append(QString::fromUtf8(mockupType.typeName()) + "{\n}\n");
QQmlComponent component(engine);
component.setData(qmlSource.toUtf8(), QUrl());
return !component.isError();
}
void NodeInstanceServer::setupMockupTypes(const QVector<MockupTypeContainer> &container)
{
for (const MockupTypeContainer &mockupType : container) {
if (!isTypeAvailable(mockupType, engine()))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
QQuickDesignerSupportMetaInfo::registerMockupObject(mockupType.importUri().toUtf8(),
QQuickDesignerSupportMetaInfo::registerMockupObject(mockupType.importUri().toUtf8(),
mockupType.majorVersion(),
mockupType.minorVersion(),
mockupType.typeName());
#else
qmlRegisterType(QUrl("qrc:/qtquickplugin/mockfiles/GenericBackend.qml"),
qmlRegisterType(QUrl("qrc:/qtquickplugin/mockfiles/GenericBackend.qml"),
mockupType.importUri().toUtf8(),
mockupType.majorVersion(),
mockupType.minorVersion(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment