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

QML ObjectModel: Following the documentation for append will lead to app crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • 6.7
    • 6.7.0
    • None
    • Windows 11 Pro 23H2 / build: 22631.3374
      CPU: Intel Core i7-8750H
      GPU: Intel UHD Graphics 630
      RAM: 16 GB
      Qt Version: 6.7.0 msvc2019_64
    • Windows

    Description

      The documentation to "append"

      in: https://doc.qt.io/qt-6/qml-qtqml-models-objectmodel.html

      has an example how to use it:

       

      objectModel.append(objectComponent.createObject()) 

      if you follow this, your app will most likely crash sooner or later, because the garbage collector will delete the created object.

       

      Two options:

      1. the documentation is correct and "append" does some "magic" to have the garbage collector not delete the item. Then the "magic" is broken.
      2. the documentation is incomplete. In this case, please add a parent to the createObject in the example. There are two other examples for "get" and "insert" where the parent is also missing.

      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
            basti_4tiitoo Bastian Wolfgruber
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes