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

QML list of length N emits (N+1) value change signals when shift() is called

XMLWordPrintable

    • 87cf75dd2 (dev)

      Code

      import QtQuick
      import QtQuick.Controls.Basic
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
      
          property list<int> numbers: [1, 2, 3, 4, 5]
          onNumbersChanged: console.log("Updated list:", numbers)
      
          Button {
              text: "Shift"
              onClicked: {
                  console.log("=== Starting shift ===")
                  root.numbers.shift()
                  console.log("=== Finished shift ===")
              }
          }
      }
      

       

      Steps to reproduce
      Run the above code and click the button

       

      Expected outcomes

      qml: === Starting shift ===
      qml: Updated list: [2,3,4,5]
      qml: === Finished shift ===
      

       

      Actual outcomes

      qml: === Starting shift ===
      qml: Updated list: [2,2,3,4,5]
      qml: Updated list: [2,3,3,4,5]
      qml: Updated list: [2,3,4,4,5]
      qml: Updated list: [2,3,4,5,5]
      qml: Updated list: [2,3,4,5,0]
      qml: Updated list: [2,3,4,5]
      qml: === Finished shift ===
      

       

      Notes
      There is a similar issue for pop():

      qml: === Starting pop ===
      qml: Updated list: [1,2,3,4,0]
      qml: Updated list: [1,2,3,4]
      qml: === Finished pop ===
      

        For Gerrit Dashboard: QTBUG-123882
        # Subject Branch Project Status CR V

            ulherman Ulf Hermann
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes