From d64bf59bb0a48016903043a006843500d255db4f Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Tue, 30 Apr 2024 23:11:54 -0700 Subject: [PATCH] core/intercept: do not rewrite paths when url ends in .qml Fixes component baseUrls becoming file:// paths which cannot access singletons. --- src/core/qsintercept.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/qsintercept.cpp b/src/core/qsintercept.cpp index 21b6abf3..2eaf498e 100644 --- a/src/core/qsintercept.cpp +++ b/src/core/qsintercept.cpp @@ -20,6 +20,11 @@ QUrl QsUrlInterceptor::intercept(const QUrl& url, QQmlAbstractUrlInterceptor::Da // Some types such as Image take into account where they are loading from, and force // asynchronous loading over a network. qsintercept is considered to be over a network. if (type == QQmlAbstractUrlInterceptor::DataType::UrlString && url.scheme() == "qsintercept") { + // Qt.resolvedUrl and context->resolvedUrl can use this on qml files, in which + // case we want to keep the intercept, otherwise objects created from those paths + // will not be able to use singletons. + if (url.path().endsWith(".qml")) return url; + auto newUrl = url; newUrl.setScheme("file"); qCDebug(logQsIntercept) << "Rewrote intercept" << url << "to" << newUrl;