From a19ab6806043591abf94868de6962a3747284da7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 28 Feb 2017 16:42:54 +0100 Subject: 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 --- src/quickcontrols2/qquickstyleselector.cpp | 6 ++++-- 1 file 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 -- cgit v1.2.3