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

Qmllint interferes with qmldir file in source directory if present

    XMLWordPrintable

Details

    • All
    • 7fae7bf04 (dev), 1b17d26a5 (6.7), 6fac3de3c (6.6), b41f4ddd0 (tqtc/lts-6.5)

    Description

      These findings resolved out of the discussions here:
          https://codereview.qt-project.org/c/qt/qtdeclarative/+/488122/3/examples/quickcontrols/filesystemexplorer/qml/FileSystemView.qml

       

      The motivation that led to this investigation where 'Unqualified access' warnings generated by qmllint. The reproducer Project consists of the following structure:

      .
      ├── CMakeLists.txt
      ├── instance.h           // QML singleton
      ├── InstanceOk.qml       
      ├── main.cpp
      ├── Main.qml
      ├── qmldir               // For qmake compatibillity
      └── subdir
          └── InstanceNok.qml 

      'instance.h' QML-Singleton simply contains an invokable function named "printHello" that is called from Main.qml, InstanceOk.qml and InstanceNok.qml.

      As the names point out, the file "InstanceNok.qml" will produce the Unqualified access warning:

      // subdir/InstanceNok.qml
      import QtQuick.Controls
      import Instance
      
      TextArea {
          id: navigation
          anchors.fill: parent
          text: Instance.printHello()
      }
      
      // produces with: ninja all_qmllint:
      Info: /home/qtwayn/Qt/qt6/qtdeclarative/examples/quickcontrols/filesystemexplorer_bugfind/InstanceOk.qml:2:1: Unused import [unused-imports]
      import Instance
      ^^^^^^
      Info: /home/qtwayn/Qt/qt6/qtdeclarative/examples/quickcontrols/filesystemexplorer_bugfind/subdir/InstanceNok.qml:2:1: Unused import [unused-imports]
      import Instance
      ^^^^^^
      Warning: /home/qtwayn/Qt/qt6/qtdeclarative/examples/quickcontrols/filesystemexplorer_bugfind/subdir/InstanceNok.qml:7:11: Unqualified access [unqualified]
          text: Instance.printHello()
                ^^^^^^^^ 

      However, if we rename the qmldir file to something else, like: qmldir_bkp and run the command: 'ninja all_qmllint' again everything is quiet and no warnings are emitted.

      We use these 'handcrafted' qmldir files all around Qts examples to enable support for qmake.

       

      Please find a minimal example attached.

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            dennisoberst Dennis Oberst
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes