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

QQuickItem destructor crash when an item created from c++ is used inside an item hierarchy with default property alias

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P1: Critical
    • None
    • 5.6.0
    • None
    • Windows MSVC2015 x64 Qt5.6 (one of the latest beta)
      Linux G++5.2 Qt5.6

    Description

      A crash occurs when a QQuickItem created from C++ is destructed if it has previously been inserted in an item hierarchy where a default property alias is used on “children”.

      The item is dynamically created from C++ from a QQmlComponent* used as an item delegate and exposed to QML with a Q_INVOKABLE “factory” method (see ItemContainer::createItem()).

      The item is created from C++ using a concrete QML component “inheriting” from a custom QQuickItem declared with qmlRegisterType() in main.cpp. There is probably an ownership confusion in the item hierarchy between C++ and QML since the concrete CustomItem QML component is based on a custom C++ QQuickItem exposed with qmlRegisterType(): CustomItem.qml “inherit” from AbstractCustomItem wich is a qmlRegisterType< CustomItem >( "MyModule", 1, 0, "AbstractCustomItem") (see the project in attachment).

      Crash also occurs when the correct CppOwnership is set on the item returned from the Q_INVOKABLE method.

      Everything is destroyed correctly when no default property alias is used.

      A minimal project with a reproducible crash is in attachment: CustomItem.qml has commented working code (with no alias...), the default version crashes.

      It also crash on Linux g++5.2-Qt5.6, but the "already destroyed quick item" children seems to be garbage collected later than on Windows. Setting all parents item to nullptr in virtual destructors for custom items with no CppOwnership just delay the problem until the GC collect the null parented items.

      Attachments

        1. QQuickItemCrash.zip
          3 kB
          Gil
        2. QtObjectCrash.zip
          13 kB
          Autheman Benoit

        Issue Links

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

          Activity

            People

              shausman Simon Hausmann
              cneben2 Autheman Benoit
              Votes:
              8 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes