Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.12.6
Description
If a C++ component provides an absolute URL (e.g. qrc:///) through a property to QML and in QML it is bound against the Image.source property and there is a QQmlFileSelector installed on the QQmlEngine, then the absolute URL isn't processed by the QQmlFileSelector before being passed to Image.source.
If the URL provided by the C++ component is however a relative URL, then the URL is processed by QQmlFileSelector before being passed to Image.source.
The reason for this different behavior is in QQmlPropertyPrivate::write(), where qmlContext->resolvedUrl(url) is only invoked if the URL is relative, however, since QQmlContextData::resolvedUrl() handles absolute URLs just fine, there is no obvious reason to restrict this call in QQmlPropertyPrivate::write() to relative URLs only.
Attached is a test case that demonstrate the issue: We export two URLs (one absolute, one relative) as context properties to QML, but only the relative one is processed successfully by QQmlFileSelector and therefore only one image is shown instead of two.