diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-11-30 05:13:42 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-11-30 05:13:42 (GMT) |
commit | 16cbe54f41ff4ff9a03ce3973c52be32d63b7138 (patch) | |
tree | a1254ae25a648834d405dd39b52e78f0f078c4ba /src/declarative/qml | |
parent | 46213b30d639505849d079b30e72ef8393e9a748 (diff) | |
download | Qt-16cbe54f41ff4ff9a03ce3973c52be32d63b7138.zip Qt-16cbe54f41ff4ff9a03ce3973c52be32d63b7138.tar.gz Qt-16cbe54f41ff4ff9a03ce3973c52be32d63b7138.tar.bz2 |
Correct ownership semantics for QObject derived types
Task-number: QTBUG-15697
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index eff59df..b0bc5bb 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -69,7 +69,7 @@ struct ObjectData : public QScriptDeclarativeClass::Object { virtual ~ObjectData() { if (object && !object->parent()) { QDeclarativeData *ddata = QDeclarativeData::get(object, false); - if (ddata && !ddata->indestructible && 0 == --ddata->objectDataRefCount) + if (ddata && !ddata->indestructible && 0 == --ddata->objectDataRefCount) object->deleteLater(); } } @@ -808,7 +808,14 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e) } return QScriptDeclarativeClass::Value(engine, rv); } else if (type == -1 || type == qMetaTypeId<QVariant>()) { - return QScriptDeclarativeClass::Value(engine, QDeclarativeEnginePrivate::get(e)->scriptValueFromVariant(*((QVariant *)&data))); + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(e); + QScriptValue rv = ep->scriptValueFromVariant(*((QVariant *)&data)); + if (rv.isQObject()) { + QObject *object = rv.toQObject(); + if (object) + QDeclarativeData::get(object, true)->setImplicitDestructible(); + } + return QScriptDeclarativeClass::Value(engine, rv); } else { return QScriptDeclarativeClass::Value(); } |