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
Issue Links
- duplicates
-
QTBUG-51927 [REG:5.6.0-alpha1->5.6.0] adding items to GridLayout with default property alias causes a crash during destruction
- Closed
- relates to
-
QTBUG-51558 [REG 5.6Beta-5.6.0] Access Violation in QQuickItem's dtor when used as a container with a layout
- Closed