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

QQmlTableInstanceModel allows access to context properties even if required properties are present

    XMLWordPrintable

Details

    • a370d086e (dev)

    Description

      Consider the following as found in our tests:

              delegate: Rectangle {
                  implicitWidth: 100
                  implicitHeight: 50
      
                  required property bool editing
      
                  Text {
                      anchors.centerIn: parent
                      text: display
                  }
      
                  [...]
              }
      

      This should not be possible. The "display" property is passed via the context here. Yet, the delegate has a required property.

      The presence of required properties should force all data access to go through required properties. Context properties and scope properties can shadow each other. We want this to be as predictable as possible at compile time. That's the whole reason for required properties to exist.

      The core of the problem is that QQmlTableInstanceModelIncubationTask duplicates QQDMIncubationTask's "incubating" member by introducing its own "modelItemToIncubate". This way, it can leave "incubating" at nullptr and effectively prevents initializeRequiredProperties() from resetting the contextObject.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes