forked from qt-creator/qt-creator
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 <tim.jenssen@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
148e5a2792
commit
cb86cc3bdd
@@ -685,10 +685,30 @@ 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(),
|
||||
mockupType.majorVersion(),
|
||||
mockupType.minorVersion(),
|
||||
|
Reference in New Issue
Block a user