Commit f01fe61f authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Hotfix for all Windows



Now all windows are exchanged with items.

Change-Id: Ieecd4410c92a1e4f63b1035843a8534e92199b98
Hotfix: 3.1
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 28e5eeac
......@@ -1044,6 +1044,39 @@ static QQmlType *getQmlType(const QString &typeName, int majorNumber, int minorN
return QQmlMetaType::qmlType(typeName.toUtf8(), majorNumber, minorNumber);
}
static bool isWindowMetaObject(const QMetaObject *metaObject)
{
if (metaObject) {
if (metaObject->className() == QByteArrayLiteral("QWindow"))
return true;
return isWindowMetaObject(metaObject->superClass());
}
return false;
}
static QObject *createDummyWindow(QQmlContext *context, const QUrl &sourceUrl)
{
QQmlComponent component(context->engine());
QByteArray dummyWindow;
dummyWindow.append("import QtQuick 2.0\n");
dummyWindow.append("Item {\n");
dummyWindow.append("property string title\n");
dummyWindow.append("}\n");
component.setData(dummyWindow, sourceUrl);
return component.create();
}
static bool isWindow(QObject *object) {
if (object)
return isWindowMetaObject(object->metaObject());
return false;
}
QObject *ObjectNodeInstance::createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context)
{
ComponentCompleteDisabler disableComponentComplete;
......@@ -1053,9 +1086,6 @@ QObject *ObjectNodeInstance::createPrimitive(const QString &typeName, int majorN
QObject *object = 0;
QQmlType *type = getQmlType(typeName, majorNumber, minorNumber);
if (typeName == "QtQuick.Window/Window")
type = getQmlType("QtQuick/Item", 2, 0);
if (type) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) // TODO remove hack later if we only support >= 5.2
if ( type->isComposite()) {
......@@ -1069,6 +1099,12 @@ QObject *ObjectNodeInstance::createPrimitive(const QString &typeName, int majorN
object = type->create();
}
}
if (isWindow(object)) {
delete object;
object = createDummyWindow(context, type->sourceUrl());
}
} else {
qWarning() << "QuickDesigner: Cannot create an object of type"
<< QString("%1 %2,%3").arg(typeName).arg(majorNumber).arg(minorNumber)
......
Supports Markdown
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