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/quick/items/qquicktext.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/quick/items/qquicktext.cpp') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index bbf6e4f8b8..79665a3cda 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1218,8 +1218,9 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal image->position < line.textStart() + line.textLength()) { if (!image->pix) { - QUrl url = q->baseUrl().resolved(image->url); - image->pix = new QQuickPixmap(qmlEngine(q), url, QRect(), image->size); + const QQmlContext *context = qmlContext(q); + const QUrl url = context->resolvedUrl(q->baseUrl()).resolved(image->url); + image->pix = new QQuickPixmap(context->engine(), url, QRect(), image->size); if (image->pix->isLoading()) { image->pix->connectFinished(q, SLOT(imageDownloadFinished())); if (!extra.isAllocated() || !extra->nbActiveDownloads) @@ -1285,7 +1286,8 @@ void QQuickTextPrivate::ensureDoc() extra.value().doc = new QQuickTextDocumentWithImageResources(q); extra->doc->setPageSize(QSizeF(0, 0)); extra->doc->setDocumentMargin(0); - extra->doc->setBaseUrl(q->baseUrl()); + const QQmlContext *context = qmlContext(q); + extra->doc->setBaseUrl(context ? context->resolvedUrl(q->baseUrl()) : q->baseUrl()); qmlobject_connect(extra->doc, QQuickTextDocumentWithImageResources, SIGNAL(imagesLoaded()), q, QQuickText, SLOT(q_updateLayout())); } -- cgit v1.2.3