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

QML import unable to disambiguate module from itself if it contains JavaScript

    XMLWordPrintable

Details

    Description

      QML import unable to disambiguate module from itself if it contains JavaScript

      A module importing modules that import a third module in common, that happens to contain a JavaScript file, will fail to import because the importer is unable to disambiguate the same JavaScript file across the modules attempting to import it. This issue will not happen if the module has only QML files.

      Error messages can vary slightly depending on how the modules are setup. Some error messages include:

      qrc:/qt/qml/ModuleD/Root.qml:4:1: module "ModuleC" version 1.0 cannot be imported because:
      "ModuleA" is ambiguous. Found in qrc:/qt/qml/ModuleA/ and in qrc:/qt/qml/ModuleA/

      And:

      qrc:/qt/qml/App/Root.qml: module "ModuleC" version 1.0 cannot be imported because:
      "ModuleA" is ambiguous. Found in qrc:/qt/qml/ModuleA/ and in qrc:/qt/qml/ModuleA/
      qrc:/qt/qml/App/Root.qml: "ModuleA" is ambiguous. Found in qrc:/qt/qml/ModuleA/ and in qrc:/qt/qml/ModuleA/
      qrc:/qt/qml/App/Root.qml: Failed to load dependent import "ModuleA" version 255.255
      qrc:/qt/qml/App/Root.qml: Failed to load dependencies for module "ModuleC" version 1.0
      qrc:/qt/qml/App/Root.qml: Failed to load dependent import "ModuleC" version 1.0

      To receive messages regarding the inability to disambiguate, the calls to qt_add_qml_module must have IMPORTS specified. If those aren't specified, the modules will still fail to import, but the explanation will be less clear. JavaScript  files will appear as unavailable despite clearly being present in Qt resources. You can use GammaRay to inspect resources if you change an app to not exist the event loop when modules fail to  import.

      Example of error message when not specifying IMPORTS on qt_add_qml_module:

      qrc:/qt/qml/App/Root.qml:14:5: Type TextB unavailable
      qrc:/qt/qml/ModuleB/TextB.qml:8:5: Type TextProviderA unavailable
      qrc:/qt/qml/ModuleA/TextProviderA.qml:3:1: Script qrc:/qt/qml/ModuleA/Utils.js unavailable
      qrc:/qt/qml/ModuleA/Utils.js: No such file or directory
      Loaded object:  QUrl("qrc:/qt/qml/App/Root.qml")
      Loading QML root failed; exiting...

      Attached are images and project files further illustrating the issue.

      Attachments

        1. 1-2.png
          970 kB
          Javier Cordero
        2. 2.png
          971 kB
          Javier Cordero
        3. 3.png
          994 kB
          Javier Cordero
        4. 4.png
          1.01 MB
          Javier Cordero
        5. 5.png
          1.13 MB
          Javier Cordero
        6. 6.png
          1.42 MB
          Javier Cordero
        7. 7.png
          1.42 MB
          Javier Cordero
        8. 8.png
          1.47 MB
          Javier Cordero
        9. diamond-module-import-bug-a.tar.gz
          2 kB
          Javier Cordero
        10. diamond-module-import-bug-b.tar.gz
          2 kB
          Javier Cordero

        Issue Links

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

          Activity

            People

              ulherman Ulf Hermann
              javier.cordero Javier Cordero
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes