aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlengine.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-04-24 10:06:19 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-04-24 11:46:49 +0200
commit1f39b8ba2745f2b9ff462d40f6b0ca473c94484e (patch)
treeeee4831d3dd961680edddcef3ac78423fc77d8c1 /src/qml/qml/qqmlengine.cpp
parentb5fa1411a0109c332ffc7c3dbe9145f7ecc2c9a7 (diff)
Move object onwership functions from QQmlEngine to QJSEngine
[ChangeLog][QML] The setObjectOwnership and objectOwnership functions have been moved from QQmlEngine to QJSEngine. This reflects the fact that they have an effect on objects passed not only to a QQmlEngine, but also to a QJSEngine. As QQmlEngine is a subclass of QJSEngine, existing code continues to work. Fixes: QTBUG-83657 Change-Id: Ib29cdb4a9884e1f1b68fcba64d32b1cb2e5a4297 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r--src/qml/qml/qqmlengine.cpp68
1 files changed, 0 insertions, 68 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 861b888942..fec4f2ba65 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1477,74 +1477,6 @@ void QQmlEngine::setContextForObject(QObject *object, QQmlContext *context)
}
/*!
- \enum QQmlEngine::ObjectOwnership
-
- 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 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.
-*/
-
-/*!
- Sets the \a ownership of \a object.
-*/
-void QQmlEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership)
-{
- if (!object)
- return;
-
- QQmlData *ddata = QQmlData::get(object, true);
- if (!ddata)
- return;
-
- ddata->indestructible = (ownership == CppOwnership)?true:false;
- ddata->explicitIndestructibleSet = true;
-}
-
-/*!
- Returns the ownership of \a object.
-*/
-QQmlEngine::ObjectOwnership QQmlEngine::objectOwnership(QObject *object)
-{
- if (!object)
- return CppOwnership;
-
- QQmlData *ddata = QQmlData::get(object, false);
- if (!ddata)
- return CppOwnership;
- else
- return ddata->indestructible?CppOwnership:JavaScriptOwnership;
-}
-
-/*!
\reimp
*/
bool QQmlEngine::event(QEvent *e)