Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80904

Absolute QRC URLs from C++ properties are not handled properly by QQmlFileSelector

    XMLWordPrintable

Details

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tokoe.kdab Tobias Koenig
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes