From f2ede1a01237c0ff0285716359a8b57a6676a94d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 23 Apr 2016 19:34:15 +0200 Subject: QQuickStyleSelector: fix relative path handling This makes it possible to pass a relative path to the style: ./myapp -style relative/path/to/my/style To make the tests pass, includes a fix to avoid double slashes in selected URLs. Change-Id: I1b366eb7793523dd0f1058236661cedaa1216f3d Reviewed-by: Mitch Curtis --- src/quickcontrols2/qquickstyleselector.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/quickcontrols2') diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp index cd89ba95..93249192 100644 --- a/src/quickcontrols2/qquickstyleselector.cpp +++ b/src/quickcontrols2/qquickstyleselector.cpp @@ -144,11 +144,15 @@ QString QQuickStyleSelector::select(const QString &fileName) const const QString selectedPath = selectionHelper(stylePath, fileName, allSelectors(false)); if (selectedPath.startsWith(QLatin1Char(':'))) return QLatin1String("qrc") + selectedPath; - return QUrl::fromLocalFile(selectedPath).toString(); + return QUrl::fromLocalFile(QFileInfo(selectedPath).absoluteFilePath()).toString(); } } - QUrl url(d->baseUrl.toString() + QLatin1Char('/') + fileName); + QString base = d->baseUrl.toString(); + if (!base.isEmpty() && !base.endsWith(QLatin1Char('/'))) + base += QLatin1Char('/'); + + QUrl url(base + fileName); if (isLocalScheme(url.scheme())) { QString equivalentPath = QLatin1Char(':') + url.path(); QString selectedPath = d->select(equivalentPath); -- cgit v1.2.3