diff options
authorFabian Kosmale <fabian.kosmale@qt.io>2021-06-17 11:10:45 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-17 12:45:26 +0000
commite607738d34d5436a85e2321478ff01641f0d58b5 (patch)
parent55a9b77788dc11bf3669ed77a91d3cb68de03b0a (diff)
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 <paul.wicking@qt.io> (cherry picked from commit 906ccb4694bbb3577efc8b8839ed687ebb3e3dce) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
1 files changed, 10 insertions, 1 deletions
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)