aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-02-07 16:59:51 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-19 15:04:55 +0100
commit75563fa761b94e049de0a29e91591610b0d15745 (patch)
treef013158c9d571a7c109572725de7cbfd1e73f51f /tools/qml
parent585ee10c63d9e69dce07674db99c92a3814da157 (diff)
Clean up QQmlFileSelector
The global static map of file selectors is not thread safe. If you add a file selector to engine A running in thread 1, you cannot at the same time retrieve the file selector of engine B running in thread 2. Alas, we only need the static map to discern file selectors from other URL interceptors, and we only need to do this on QQmlFileSelector::get(), which we don't use. Unfortunately it is public API, though. Deprecate QQmlFileSelector::get() and add a different hack to discern the interceptors for the case that it's still called. Also remove the duplicate setExtraSelectors() method. For this to work, we also add a method to QQmlApplicationEngine that allows us to pass extra file selectors and delay the initialization of QQmlApplicationEngine's QQmlFileSelector until the first file is loaded. [ChangeLog][QML] QQmlFileSelector::get() is deprecated. You can use the new method QQmlAplicationEngine::setExtraFileSelectors() to pass extra selectors to QQmlApplicationEngine's internal QQmlFileSelector. Manually created QQmlFileSelectors should be configured immediately after creation, before they are used by the QQmlEngine. Change-Id: Ia61a93777dc910b441a03ffb42d35a2a224c0e26 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qml')
-rw-r--r--tools/qml/main.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index e8c471e22e..a38a3d599f 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -558,10 +558,9 @@ int main(int argc, char *argv[])
QStringList customSelectors;
for (const QString &selector : parser.values(selectorOption))
customSelectors.append(selector);
- if (!customSelectors.isEmpty()) {
- QQmlFileSelector *selector = QQmlFileSelector::get(&e);
- selector->setExtraSelectors(customSelectors);
- }
+
+ if (!customSelectors.isEmpty())
+ e.setExtraFileSelectors(customSelectors);
#if defined(QT_GUI_LIB) && QT_CONFIG(opengl)
if (qEnvironmentVariableIsSet("QSG_CORE_PROFILE") || qEnvironmentVariableIsSet("QML_CORE_PROFILE")) {