From 75563fa761b94e049de0a29e91591610b0d15745 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 7 Feb 2020 16:59:51 +0100 Subject: 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 --- src/qml/qml/qqmlfileselector.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/qml/qml/qqmlfileselector.h') diff --git a/src/qml/qml/qqmlfileselector.h b/src/qml/qml/qqmlfileselector.h index 362a15a27e..0aeea6775f 100644 --- a/src/qml/qml/qqmlfileselector.h +++ b/src/qml/qml/qqmlfileselector.h @@ -59,7 +59,10 @@ public: QFileSelector *selector() const Q_DECL_NOTHROW; void setSelector(QFileSelector *selector); void setExtraSelectors(const QStringList &strings); - static QQmlFileSelector* get(QQmlEngine*); + +#if QT_DEPRECATED_SINCE(6, 0) + QT_DEPRECATED static QQmlFileSelector *get(QQmlEngine*); +#endif private: Q_DISABLE_COPY(QQmlFileSelector) -- cgit v1.2.3