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

QT_DISCARD_FILE_CONTENTS does not work as expected

XMLWordPrintable

    • 7d433ad2e (dev), 6aee2b7d1 (6.10), 4006bb120 (6.9), bcbbcd24c (tqtc/lts-6.8), fa306a6e6 (tqtc/lts-6.5)

      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.

        1. QTBUG-138158.zip
          1 kB
          Joshua GPBeta
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved: