forked from qt-creator/qt-creator
QmlDesigner: Fix url property path resolving
Converting file:// urls to relative paths assumed that the file://
url would always point to a file that is in same or child folder of
the qml document, which broke for urls that pointed under generated
components folder.
Fixes: QDS-12029
Change-Id: I352ba01650ebf6c1c5fedef9323bf27b44491736
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Shrief Gabr <shrief.gabr@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
(cherry picked from commit 6cec311c5d
)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <qmlprivategate.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QEvent>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlError>
|
||||
@@ -627,8 +628,8 @@ QVariant ObjectNodeInstance::property(const PropertyName &name) const
|
||||
return QVariant();
|
||||
|
||||
if (url.scheme() == "file") {
|
||||
int basePathLength = nodeInstanceServer()->fileUrl().toLocalFile().lastIndexOf('/');
|
||||
return QUrl(url.toLocalFile().mid(basePathLength + 1));
|
||||
QFileInfo fi{nodeInstanceServer()->fileUrl().toLocalFile()};
|
||||
return QUrl{fi.absoluteDir().relativeFilePath(url.toLocalFile())};
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user