diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-03 06:47:55 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-03 06:47:55 (GMT) |
commit | 79d35acae62bf28c37022b763b04e94f5e67bf6f (patch) | |
tree | afdf4ec79438cee1058927f6e23d3184f8450618 /src/declarative/qml | |
parent | ed82a5dbe57fcc80b9d6244c73295f4b0b6e2835 (diff) | |
download | Qt-79d35acae62bf28c37022b763b04e94f5e67bf6f.zip Qt-79d35acae62bf28c37022b763b04e94f5e67bf6f.tar.gz Qt-79d35acae62bf28c37022b763b04e94f5e67bf6f.tar.bz2 |
Define and document deletion of QmlEngine QNetworkAccessManager
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 7242a1d..c562e02 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -181,8 +181,6 @@ QmlEnginePrivate::~QmlEnginePrivate() typeNameClass = 0; delete listClass; listClass = 0; - delete networkAccessManager; - networkAccessManager = 0; delete nodeListClass; nodeListClass = 0; delete namedNodeMapClass; @@ -336,14 +334,16 @@ QmlContext *QmlEngine::rootContext() Sets the common QNetworkAccessManager, \a network, used by all QML elements instantiated by this engine. - Any previously set manager is deleted and \a network is owned by the - QmlEngine. This method should only be called before any QmlComponents are - instantiated. + If the parent of \a network is this engine, the engine takes ownership and + will delete it as needed. Otherwise, ownership remains with the caller. + + This method should only be called before any QmlComponents are instantiated. */ void QmlEngine::setNetworkAccessManager(QNetworkAccessManager *network) { Q_D(QmlEngine); - delete d->networkAccessManager; + if (d->networkAccessManager && d->networkAccessManager->parent() == this) + delete d->networkAccessManager; d->networkAccessManager = network; } @@ -358,7 +358,7 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const { Q_D(const QmlEngine); if (!d->networkAccessManager) - d->networkAccessManager = new QNetworkAccessManager; + d->networkAccessManager = new QNetworkAccessManager(const_cast<QmlEngine*>(this)); return d->networkAccessManager; } |