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/qml/qml/qqmlproperty.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src/qml/qml/qqmlproperty.cpp') diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index adfa76ea24..5a2c87f221 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1100,8 +1100,7 @@ QVariant QQmlPropertyPrivate::readValueProperty() } // helper function to allow assignment / binding to QList properties. -QVariant QQmlPropertyPrivate::resolvedUrlSequence( - const QVariant &value, const QQmlRefPointer &context) +QVariant QQmlPropertyPrivate::urlSequence(const QVariant &value) { QList urls; if (value.userType() == qMetaTypeId()) { @@ -1126,17 +1125,7 @@ QVariant QQmlPropertyPrivate::resolvedUrlSequence( urls.append(QUrl(urlStrings.at(i))); } // note: QList is not currently supported. - QList resolvedUrls; - const int urlsSize = urls.size(); - resolvedUrls.reserve(urlsSize); - for (int i = 0; i < urlsSize; ++i) { - QUrl u = urls.at(i); - if (context && u.isRelative() && !u.isEmpty()) - u = context->resolvedUrl(u); - resolvedUrls.append(u); - } - - return QVariant::fromValue >(resolvedUrls); + return QVariant::fromValue >(urls); } //writeEnumProperty MIRRORS the relelvant bit of QMetaProperty::write AND MUST BE KEPT IN SYNC! @@ -1318,11 +1307,9 @@ bool QQmlPropertyPrivate::write( else return false; - if (context && u.isRelative() && !u.isEmpty()) - u = context->resolvedUrl(u); return property.writeProperty(object, &u, flags); } else if (propertyType == qMetaTypeId>()) { - QList urlSeq = resolvedUrlSequence(value, context).value>(); + QList urlSeq = urlSequence(value).value>(); return property.writeProperty(object, &urlSeq, flags); } else if (property.isQList()) { QQmlMetaObject listType; -- cgit v1.2.3