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

[Reg 5.15 -> 6.5] qmlimportscanner does not include module versions

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.9
    • 6.5.4
    • QML: Tooling
    • None

    Description

      Running qmlimportscanner against QML files silently results in output which only includes the module names, but not their versions.

      Simple input QML file:

      > grep ^import Page.qml 
      import QtQuick 2.5
      import QtQuick.Layouts 1.2
      import QtQuick.Templates 2.1 as T2
      import QtQuick.Controls 2.1 as QQC2
      import org.kde.kirigami 2.10 as Kirigami
      import "private" as P
      
      > ./libexec/qt6/qmlimportscanner -qmlFiles Page.qml
      [
          {
              "name": "QtQuick",
              "type": "module"
          },
          {
              "name": "QtQuick.Layouts",
              "type": "module"
          },
          {
              "name": "QtQuick.Templates",
              "type": "module"
          },
          {
              "name": "QtQuick.Controls",
              "type": "module"
          },
          {
              "name": "org.kde.kirigami",
              "type": "module"
          },
          {
              "name": "private",
              "path": "Page.qml/private",
              "type": "directory"
          }
      ]
      

      With an older version (in this case 5.15), it works as expected:

      > qmlimportscanner-qt5 -qmlFiles Page.qml
      [
          {
              "name": "QtQuick",
              "type": "module",
              "version": "2.5"
          },
          {
              "name": "QtQuick.Layouts",
              "type": "module",
              "version": "1.2"
          },
          {
              "name": "QtQuick.Templates",
              "type": "module",
              "version": "2.1"
          },
          {
              "name": "QtQuick.Controls",
              "type": "module",
              "version": "2.1"
          },
          {
              "name": "org.kde.kirigami",
              "type": "module",
              "version": "2.10"
          },
          {
              "name": "private",
              "path": "Page.qml/private",
              "type": "directory"
          }
      ]
      

      It works after removing a single line in qmlimportscanner:

      diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
      index 7c8f1bc98e..c8635323ce 100644
      --- a/tools/qmlimportscanner/main.cpp
      +++ b/tools/qmlimportscanner/main.cpp
      @@ -434,7 +434,6 @@ getImportDetails(const QVariant &inputImport,
                   import.insert(preferLiteral(), prefer);
               }
           }
      -    import.remove(versionLiteral());
       
           const ImportDetailsAndDeps result = {import, dependencies};
           cache.insert({inputImport, result});
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-115170
          # Subject Branch Project Status CR V

          Activity

            People

              qtqmlteam Qt Qml Team User
              vogtinator Fabian Vogt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change