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

Error when accessing StackView attached properties via popped item

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.6
    • Quick: Controls 2
    • None
    • 1cf60c89a8711103a37b0511f4e91ee28d984b45

    Description

      The following code will produce a error right before the instance of page2Component has been destroyed (when its transition finishes):

      import QtQuick 2.6
      import QtQuick.Window 2.2
      import Qt.labs.controls 1.0
      
      Window {
          visible: true
      
          StackView {
              anchors.fill: parent
              initialItem: page1Component
      
              Component {
                  id: page1Component
      
                  Rectangle {
                      id: root
      
                      Text {
                          text: "Page 1"
                          font.pixelSize: 40
                          anchors.centerIn: parent
                      }
      
                      Button {
                          text: "Push"
                          onClicked: root.StackView.view.push(page2Component)
                      }
                  }
              }
      
              Component {
                  id: page2Component
      
                  Rectangle {
                      id: root
      
                      Text {
                          text: "Page 2"
                          font.pixelSize: 40
                          anchors.centerIn: parent
                      }
      
                      property bool someBinding: root.StackView.view.currentItem === root
      
                      Button {
                          text: "Pop"
                          onClicked: root.StackView.view.pop()
                      }
                  }
              }
          }
      }
      

      StackView's attached properties should be available until the component is destroyed.

      We can't make the same guarantee for pre-existing items that are pushed, but for components, it's nice to not have to add lots of null checks.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes