Details
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
For Gerrit Dashboard: QTBUG-115478 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
542286,2 | qmllint: With --bare do not use the current directory | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
542841,2 | qmllint: With --bare do not use the current directory | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
542981,2 | qmllint: With --bare do not use the current directory | 6.6 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
542985,2 | qmllint: With --bare do not use the current directory | tqtc/lts-6.5 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |