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

QT_DISCARD_FILE_CONTENTS does not work as expected

    XMLWordPrintable

Details

    Description

      Components become invisible to the QML engine when applying QT_DISCARD_FILE_CONTENTS option to the QML source files:

      set_source_files_properties(
             main.qml
          PROPERTIES
              QT_DISCARD_FILE_CONTENTS TRUE
      )
      
      qt_add_resources(appmulti-module "main_qml"
          PREFIX "/"
          FILES main.qml
      ) 

      Running the application ends up with an error:

      QQmlApplicationEngine failed to load component
      qrc:/main.qml: File is empty

      Since Qt 6.10, qt_add_resources() introduces the new option DISCARD_FILE_CONTENTS, which does not work either.

      This issue does not occur when using qt_add_qml_module() function with the DISCARD_QML_CONTENTS option. But if we define multiple QML modules in a single CMakeLists.txt, there will be a similar problem.

      The attachment contains a minimum reproduce project.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            gpbeta Joshua GPBeta
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There is 1 open Gerrit change