diff options
author | Kavindra Palaraja <kavindra.d@gmail.com> | 2014-09-16 20:36:19 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-09-16 20:37:22 +0200 |
commit | cfe1a8152c948a4586ffa1fe79b47f9a0e88beb5 (patch) | |
tree | 318298b1ca1542a7342e0af3fad7f64bfd5c8a4b /src/qml/qml | |
parent | 3fee095bac4c2c777119c13e201777d3202ae084 (diff) |
Cleaned up the documentation for QQmlEngine::ObjectOwnership.
The paragraphs needed a bit of polish.
Change-Id: I5c6b41fad34f3f58a372aa1bf8be627769871cf8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 7e66cce490..2b69661c4b 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1247,42 +1247,38 @@ void QQmlEngine::setContextForObject(QObject *object, QQmlContext *context) /*! \enum QQmlEngine::ObjectOwnership - Ownership controls whether or not QML automatically destroys the - QObject when the object is garbage collected by the JavaScript - engine. The two ownership options are: - - \value CppOwnership The object is owned by C++ code, and will - never be deleted by QML. The JavaScript destroy() method cannot be - used on objects with CppOwnership. This option is similar to - QScriptEngine::QtOwnership. - - \value JavaScriptOwnership The object is owned by JavaScript. - When the object is returned to QML as the return value of a method - call, QML will track it, and delete the object - if there are no remaining JavaScript references to it and it has no - QObject::parent(). An object tracked by one QQmlEngine - will be deleted during that QQmlEngine's destructor, and thus - JavaScript references between objects with JavaScriptOwnership from - two different engines will not be valid after the deletion of one of - those engines. This option is similar to QScriptEngine::ScriptOwnership. + ObjectOwnership controls whether or not QML automatically destroys the + QObject when the corresponding JavaScript object is garbage collected by the + engine. The two ownership options are: + + \value CppOwnership The object is owned by C++ code and QML will never delete + it. The JavaScript destroy() method cannot be used on these objects. This + option is similar to QScriptEngine::QtOwnership. + + \value JavaScriptOwnership The object is owned by JavaScript. When the object + is returned to QML as the return value of a method call, QML will track it + and delete it if there are no remaining JavaScript references to it and + it has no QObject::parent(). An object tracked by one QQmlEngine will be + deleted during that QQmlEngine's destructor. Thus, JavaScript references + between objects with JavaScriptOwnership from two different engines will + not be valid if one of these engines is deleted. This option is similar to + QScriptEngine::ScriptOwnership. Generally an application doesn't need to set an object's ownership - explicitly. QML uses a heuristic to set the default object - ownership. By default, an object that is created by QML has - JavaScriptOwnership. The exception to this are the root objects - created by calling QQmlComponent::create() or - QQmlComponent::beginCreate() which have CppOwnership by - default. The ownership of these root-level objects is considered to - have been transferred to the C++ caller. - - Objects not-created by QML have CppOwnership by default. The - exception to this is objects returned from C++ method calls; in these cases, - the ownership of the returned objects will be set to JavaScriptOwnerShip. - Note this applies only to explicit invocations of Q_INVOKABLE methods or slots, - and not to property getter invocations. - - Calling setObjectOwnership() overrides the default ownership - heuristic used by QML. + explicitly. QML uses a heuristic to set the default ownership. By default, an + object that is created by QML has JavaScriptOwnership. The exception to this + are the root objects created by calling QQmlComponent::create() or + QQmlComponent::beginCreate(), which have CppOwnership by default. The + ownership of these root-level objects is considered to have been transferred + to the C++ caller. + + Objects not-created by QML have CppOwnership by default. The exception to this + are objects returned from C++ method calls; their ownership will be set to + JavaScriptOwnership. This applies only to explicit invocations of Q_INVOKABLE + methods or slots, but not to property getter invocations. + + Calling setObjectOwnership() overrides the default ownership heuristic used by + QML. */ /*! |