Allow objects created in QML with incubateObject to be destroyed.
[profile/ivi/qtdeclarative.git] / tests / auto / qml / qqmlecmascript / data / ownershipQmlIncubated.qml
1 import QtQuick 2.0
2
3 Item {
4     id: root
5
6     property QtObject incubatedItem
7
8     Component.onCompleted: {
9         var component = Qt.createComponent("PropertyVarBaseItem.qml");
10
11         var incubator = component.incubateObject(root);
12         if (incubator.status != Component.Ready) {
13             incubator.onStatusChanged = function(status) {
14                 if (status == Component.Ready) {
15                     incubatedItem = incubator.object;
16                 }
17             }
18         } else {
19             incubatedItem = incubator.object;
20         }
21     }
22
23     function deleteIncubatedItem() {
24         incubatedItem.destroy();
25         gc();
26     }
27 }