From: Kai Koehne Date: Thu, 6 Jun 2013 13:18:57 +0000 (+0200) Subject: Doc: Clarify object ownership of QObject* returned by QmlComponent::create X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b1ee75d377fc9517d67047c8fe6929c49cc4bd01;p=konrad%2Fqtdeclarative.git Doc: Clarify object ownership of QObject* returned by QmlComponent::create Link to relevant section in QQmlEngine::ObjectOwnership. It's a big gotcha that a QObject * returned by a Qt method won't be deleted eventually, by default. Change-Id: I2367b7ae2673adc7fa181b759c79683091020462 Reviewed-by: Thomas Hartmann Reviewed-by: Alan Alpert --- diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index ccef0a6..1fa1c23 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -767,6 +767,11 @@ QQmlComponent::QQmlComponent(QQmlComponentPrivate &dd, QObject *parent) If \a context is 0 (the default), it will create the instance in the engine' s \l {QQmlEngine::rootContext()}{root context}. + + The ownership of the returned object instance is determined by the QQmlEngine. + By default the caller has to take care that the object is eventually deleted. + + \sa QQmlEngine::ObjectOwnership */ QObject *QQmlComponent::create(QQmlContext *context) { @@ -805,7 +810,10 @@ QObject *QQmlComponent::create(QQmlContext *context) communicate information to an instantiated component, as it allows their initial values to be configured before property bindings take effect. - \sa completeCreate() + The ownership of the returned object instance is determined by the QQmlEngine. + By default the caller has to take care that the object is eventually deleted. + + \sa completeCreate(), QQmlEngine::ObjectOwnership */ QObject *QQmlComponent::beginCreate(QQmlContext *publicContext) {