aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-02-28 16:42:54 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-03-01 08:09:04 +0000
commita19ab6806043591abf94868de6962a3747284da7 (patch)
tree297d908f4d5b8588bd63be9f3151498ca645985b
parente7409625f24ed8a32bb303b948bfdf077b74ea77 (diff)
Make QQuickStyleSelector::select() more robust
While debugging QTBUG-59026, I found out that QLocale::name() is empty with the "C" locale. Because the empty locale name was used as a selector in QQuickStyleSelector, it ended up registering QML types using URLs that contained a double slash (empty locale selector matched): QtQuick/Controls.2/Material//RadioButton.qml At the same time, the QML engine imported implicitly internal QML types constructing the URLs directly based on the location on the file system without a double slash: QtQuick/Controls.2/Material/RadioIndicator.qml As a result, the same QML module ended up having types registered from two different URLs, which is not allowed. This change simply prevents both problems. First of all, if the locale name is empty for any reason, it won't be added anymore to the list of selectors. Furthermore, the final selected URL is normalized to avoid redundant dashes. Task-number: QTBUG-59026 Change-Id: I19b890451aaddfe4277bb6b26bc3c1394a75a704 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quickcontrols2/qquickstyleselector.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp
index e20096c9..6d04c190 100644
--- a/src/quickcontrols2/qquickstyleselector.cpp
+++ b/src/quickcontrols2/qquickstyleselector.cpp
@@ -69,7 +69,9 @@ static QStringList allSelectors(const QString &style = QString())
{
static const QStringList platformSelectors = QFileSelectorPrivate::platformSelectors();
QStringList selectors = platformSelectors;
- selectors += QLocale().name();
+ const QString locale = QLocale().name();
+ if (!locale.isEmpty())
+ selectors += locale;
if (!style.isEmpty())
selectors.prepend(style);
return selectors;
@@ -161,7 +163,7 @@ QString QQuickStyleSelector::select(const QString &fileName) const
} else if (url.isLocalFile()) {
url = QUrl::fromLocalFile(d->select(url.toLocalFile()));
}
- return url.toString();
+ return url.toString(QUrl::NormalizePathSegments);
}
QT_END_NAMESPACE