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

qmllint guesses wrong about scope in so-called unqualified access

    XMLWordPrintable

Details

    • d3942c4af5 (qt/qtwebengine/dev)

    Description

      In qtwebengine/examples/pdf/pdfviewer we have

          PdfScrollablePageView {
              id: view
              anchors.fill: parent
              anchors.leftMargin: searchDrawer.position * searchDrawer.width
              document: PdfDocument {
                  id: document
                  source: Qt.resolvedUrl(root.source)
                  onStatusChanged: if (status === PdfDocument.Error) errorDialog.open()
                  onPasswordRequired: {
                      passwordDialog.open()
                      passwordField.forceActiveFocus()
                  }
              }
              searchString: searchField.text
          }
      

      qmllint says

      Warning: viewer.qml:240:34: Unqualified access
                  onStatusChanged: if (status === PdfDocument.Error) errorDialog.open()
                                       ^^^^^^
      Info: status is a member of a parent element
            You can qualify the access with its id to avoid this warning:
      
                  onStatusChanged: if (view.status === PdfDocument.Error) errorDialog.open()
                                       ^^^^^
      

      I would not call this unqualified access; if unqualified "onStatusChanged" makes sense, then accessing the same status property inside the signal handler function should also be unambiguous.

      Anyway, PdfDocument has a status property; that's the one I am referring to, clearly. PdfScrollablePageView also has a status property (an alias, since PdfScrollablePageView is also implemented in QML), but qmllint should not get confused about it.  The advice is misleading.

      (I'm working with a few patches on top of dev branch in qtpdf, but I think you will see it the same without them)

      Attachments

        Issue Links

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

          Activity

            People

              max.goldstein Maximilian Goldstein
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes