Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.2.0
-
None
-
Ubuntu 13.04 x64, stock gcc
-
qtquickcontrols:37b8de375bf6145bced8264b280dfd10e114ff3a
Description
Look at the following example (also linked to the report), if you click the item and trigger the action, the latter obviously gets destructed, and crashes the application:
import QtQuick 2.1 import QtQuick.Controls 1.1 Item { width: 400; height: 200 Action { id: action2 text: "Action2" } Menu { id: menu MenuItem { id: menuItem action: Action { id: action1 text: "Action1" onTriggered: { menuItem.action = action2 } } } } //how this should have prevented GC-ing property QtObject action1Ref: action1 MouseArea { anchors.fill: parent onClicked: menu.popup() } }
The console output is:
Object 0xf98140 destroyed while one of its QML signal handlers is in progress.
Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop.
This behavior is NOT supported!
<Unknown File>:65535: function()Unknown macro: { [code] }The program has unexpectedly finished.
Note that there's a reference to the action in the scene, which should have prevented destruction in the first place, but even despite that, garbage-collected actions should probably account for coming out of scope in an onTriggered handler, and use deleteLater (just like the console warning says).
Attachments
For Gerrit Dashboard: QTBUG-37554 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
81241,1 | MenuItem: Don't delete owned bound actions | stable | qt/qtquickcontrols | Status: MERGED | +2 | 0 |