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

Details

    Description

      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 ===
      

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes