diff options
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-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 e54e23813d..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 or property access, 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. */ /*! |