From 0a1e4cc7ec7548f6273befff9cdddb0bc7a58961 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 15 Jun 2020 17:53:16 +0200 Subject: Do not resolve URLs when assigning them to a property We don't know in advance if a URL is part of the source code and should be relative to the current element, or if it is part of the application data and should not be touched. [ChangeLog][QtQml][Important Behavior Changes] URLs are not resolved or intercepted anymore when assigning them to a "url" property. Instead they are resolved and possibly intercepted when used to access an actual resource. Fixes: QTBUG-76879 Change-Id: Iaa2385aff2c13aa71a12e57385d9afb5dc60a073 Reviewed-by: Fabian Kosmale --- src/qmlworkerscript/qquickworkerscript.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/qmlworkerscript/qquickworkerscript.cpp') diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp index 3c8d9d15d6..a5d2fe6e87 100644 --- a/src/qmlworkerscript/qquickworkerscript.cpp +++ b/src/qmlworkerscript/qquickworkerscript.cpp @@ -553,8 +553,10 @@ void QQuickWorkerScript::setSource(const QUrl &source) m_source = source; - if (engine()) - m_engine->executeUrl(m_scriptId, m_source); + if (engine()) { + const QQmlContext *context = qmlContext(this); + m_engine->executeUrl(m_scriptId, context ? context->resolvedUrl(m_source) : m_source); + } emit sourceChanged(); } @@ -614,7 +616,8 @@ QQuickWorkerScriptEngine *QQuickWorkerScript::engine() { if (m_engine) return m_engine; if (m_componentComplete) { - QQmlEngine *engine = qmlEngine(this); + const QQmlContext *context = qmlContext(this); + QQmlEngine *engine = context ? context->engine() : nullptr; if (!engine) { qWarning("QQuickWorkerScript: engine() called without qmlEngine() set"); return nullptr; @@ -628,7 +631,7 @@ QQuickWorkerScriptEngine *QQuickWorkerScript::engine() m_scriptId = m_engine->registerWorkerScript(this); if (m_source.isValid()) - m_engine->executeUrl(m_scriptId, m_source); + m_engine->executeUrl(m_scriptId, context->resolvedUrl(m_source)); emit readyChanged(); -- cgit v1.2.3