From e607738d34d5436a85e2321478ff01641f0d58b5 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 17 Jun 2021 11:10:45 +0200 Subject: Add more links to QJSEngine's ownership documentation Also explictily mention again that objects with JS ownership won't be deleted as long as they have a parent. Change-Id: I1eeb5bc8183b6621f24f3751b8152b36acf2eeae Reviewed-by: Paul Wicking (cherry picked from commit 906ccb4694bbb3577efc8b8839ed687ebb3e3dce) Reviewed-by: Qt Cherry-pick Bot --- src/qml/jsapi/qjsengine.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 37b5306897..b1db348287 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -1076,7 +1076,7 @@ QJSEngine *qjsEngine(const QObject *object) 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. the JavaScript + Generally an application doesn't need to set an object's ownership explicitly. The JavaScript memory manager uses a heuristic to set the default ownership. By default, an object that is created by the JavaScript memory manager has JavaScriptOwnership. The exception to this are the root objects created by calling QQmlComponent::create() or QQmlComponent::beginCreate(), which @@ -1089,10 +1089,17 @@ QJSEngine *qjsEngine(const QObject *object) but not to property getter invocations. Calling setObjectOwnership() overrides the default ownership. + + \sa {Data Ownership} */ /*! Sets the \a ownership of \a object. + + An object with \c JavaScriptOwnership is not garbage collected as long + as it still has a parent, even if there are no references to it. + + \sa QJSEngine::ObjectOwnership */ void QJSEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership) { @@ -1109,6 +1116,8 @@ void QJSEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership) /*! Returns the ownership of \a object. + + \sa QJSEngine::ObjectOwnership */ QJSEngine::ObjectOwnership QJSEngine::objectOwnership(QObject *object) { -- cgit v1.2.3