summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2011-06-14 12:26:08 +0200
committerhjk <qthjk@ovi.com>2011-06-14 12:47:07 +0200
commit0beb721fc882741f2b5e42dfae5cab09d4c6b2a8 (patch)
treecb8597d42ad233a62615148f0f7836bceb7a704c
parentf35c4145a3a70885dc5255ceab507594d9e02b29 (diff)
downloadqt-creator-0beb721fc882741f2b5e42dfae5cab09d4c6b2a8.tar.gz
QmlDesigner.nodeInstances: fix for incompatible Qt Version
If the Qt Version is incomaptible (e. g. mingw) we have to use the qml file for a component shipped with Creator. Otherwise a import "." statement will break the component. Change-Id: I7e354a15205567407533579f92e65f2be73a614ex Reviewed-on: http://codereview.qt.nokia.com/474 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: hjk <qthjk@ovi.com>
-rw-r--r--src/plugins/qmldesigner/designercore/instances/objectnodeinstance.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/plugins/qmldesigner/designercore/instances/objectnodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/objectnodeinstance.cpp
index f36261027b..6f1e9098be 100644
--- a/src/plugins/qmldesigner/designercore/instances/objectnodeinstance.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/objectnodeinstance.cpp
@@ -60,6 +60,7 @@
#include <QGraphicsObject>
#include <QTextDocument>
+#include <QLibraryInfo>
#include <private/qdeclarativebinding_p.h>
#include <private/qdeclarativemetatype_p.h>
@@ -736,10 +737,31 @@ void tweakObjects(QObject *object)
}
+//The component might also be shipped with Creator.
+//To avoid trouble with import "." we use the component shipped with Creator.
+static inline QString fixComponentPathForIncompatibleQt(const QString &componentPath)
+{
+ QString result = componentPath;
+ const QLatin1String importString("import");
+
+ if (componentPath.contains(importString)) {
+ int index = componentPath.indexOf(importString) + 7;
+ const QString relativeImportPath = componentPath.right(componentPath.length() - index);
+ QString fixedComponentPath = QLibraryInfo::location(QLibraryInfo::ImportsPath) + relativeImportPath;
+ fixedComponentPath.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ if (QFileInfo(fixedComponentPath).exists())
+ return fixedComponentPath;
+ }
+
+ return result;
+
+}
+
QObject *createComponent(const QString &componentPath, QDeclarativeContext *context)
{
- QDeclarativeComponent component(context->engine(), QUrl::fromLocalFile(componentPath));
+ QDeclarativeComponent component(context->engine(), QUrl::fromLocalFile(fixComponentPathForIncompatibleQt(componentPath)));
QObject *object = component.beginCreate(context);
+
tweakObjects(object);
component.completeCreate();