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

Dynamic generation of PieSeries from javascript cause warning "QList::insert(): Index out of range."

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.0
    • Charts
    • None
    • Tested on Qt 5.15.0, on windows when compiling with MSVC2019 64bits

    Description

      When generating a PieSeries from a model using the functions clear and append] of PieSeries a warning is generated at the execution.

       

      With this code for example :

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtCharts 2.15
      import QtQuick.Controls 2.15
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          ListModel {
              id: exampleModel
      
              ListElement {
                  label: "A"
                  value: 2.45
              }
              ListElement {
                  label: "B"
                  value: 3.25
              }
              ListElement {
                  label: "C"
                  value: 1.95
              }
          }
      
          ChartView {
              anchors.fill: parent
      
              legend.alignment: Qt.AlignBottom
              antialiasing: true
      
              PieSeries {
                  id: examplePieSeries
              }
      
              QtObject {
                  property var model: exampleModel
      
                  function refreshPieSeries() {
                      examplePieSeries.clear()
                      let modelLenght = model.count
                      for (var i = 0; i < modelLenght; ++i) {
                          console.log("Before append " + i)
                          console.log("Label : " + model.get(i).label)
                          console.log("Value : " + model.get(i).value)
                          var pieslice = examplePieSeries.append(model.get(i).label,
                                                                 model.get(i).value)
                          console.log("After append " + i)
                      }
                  }
      
                  Component.onCompleted: {
                      refreshPieSeries()
                  }
      
                  onModelChanged: {
                      refreshPieSeries()
                  }
              }
          }
      }
      

      The output is :

      qml: Before append 0
      qml: Label : A
      qml: Value : 2.45
      qml: After append 0
      qml: Before append 1
      qml: Label : B
      qml: Value : 3.25
      qml: After append 1
      qml: Before append 2
      qml: Label : C
      qml: Value : 1.95
      qml: After append 2
      qml: Before append 0
      qml: Label : A
      qml: Value : 2.45
      QList::insert(): Index out of range.
      qml: After append 0
      qml: Before append 1
      qml: Label : B
      qml: Value : 3.25
      qml: After append 1
      qml: Before append 2
      qml: Label : C
      qml: Value : 1.95
      qml: After append 2

      Attachments

        1. CMakeLists.txt
          1 kB
        2. main.cpp
          0.6 kB
        3. main.qml
          2 kB
        4. qml.qrc
          0.1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            e0348803 Miikka Heikkinen
            vincentbaijot Vincent Baijot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes