summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp')
-rw-r--r--src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
index d22798d..36e9721 100644
--- a/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
+++ b/src/declarative/qml/qdeclarativenetworkaccessmanagerfactory.cpp
@@ -46,27 +46,44 @@ QT_BEGIN_NAMESPACE
/*!
\class QDeclarativeNetworkAccessManagerFactory
\since 4.7
- \brief The QDeclarativeNetworkAccessManagerFactory class provides a factory for QNetworkAccessManager for use by a Qt Declarative engine.
+ \brief The QDeclarativeNetworkAccessManagerFactory class creates QNetworkAccessManager instances for a QML engine.
- QNetworkAccessManager is used for all network access by QML.
- By implementing a factory it is possible to create custom
- QNetworkAccessManager with specialized caching, proxy and
- cookie support.
+ A QML engine uses QNetworkAccessManager for all network access.
+ By implementing a factory, it is possible to provide the QML engine
+ with custom QNetworkAccessManager instances with specialized caching,
+ proxy and cookies support.
- To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and implement
- the create() method.
+ To implement a factory, subclass QDeclarativeNetworkAccessManagerFactory and
+ implement the virtual create() method, then assign it to the relevant QML
+ engine using QDeclarativeEngine::setNetworkAccessManagerFactory().
- To use a factory, assign it to the relevant QDeclarativeEngine using
- QDeclarativeEngine::setNetworkAccessManagerFactory().
+ Note the QML engine may create QNetworkAccessManager instances
+ from multiple threads. Because of this, the implementation of the create()
+ method must be \l{Reentrancy and Thread-Safety}{reentrant}. In addition,
+ the developer should be careful if the signals of the object to be
+ returned from create() are connected to the slots of an object that may
+ be created in a different thread:
- Note: the create() method may be called by multiple threads, so ensure the
- implementation of this method is reentrant.
+ \list
+ \o The QML engine internally handles all requests, and cleans up any
+ QNetworkReply objects it creates. Receiving the
+ QNetworkAccessManager::finished() signal in another thread may not
+ provide the receiver with a valid reply object if it has already
+ been deleted.
+ \o Authentication details provided to QNetworkAccessManager::authenticationRequired()
+ must be provided immediately, so this signal cannot be connected as a
+ Qt::QueuedConnection (or as the default Qt::AutoConnection from another
+ thread).
+ \endlist
+
+ For more information about signals and threads, see
+ \l {Threads and QObjects} and \l {Signals and Slots Across Threads}.
- \sa QDeclarativeEngine::setNetworkAccessManagerFactory(), {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example}
+ \sa {declarative/cppextensions/networkaccessmanagerfactory}{NetworkAccessManagerFactory example}
*/
/*!
- The destructor is empty.
+ Destroys the factory. The default implementation does nothing.
*/
QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactory()
{
@@ -75,13 +92,9 @@ QDeclarativeNetworkAccessManagerFactory::~QDeclarativeNetworkAccessManagerFactor
/*!
\fn QNetworkAccessManager *QDeclarativeNetworkAccessManagerFactory::create(QObject *parent)
- Implement this method to create a QNetworkAccessManager with \a parent.
- This allows proxies, caching and cookie support to be setup appropriately.
-
- This method must return a new QNetworkAccessManager each time it is called.
- The parent of the QNetworkAccessManager must be the \a parent provided.
- The QNetworkAccessManager(s) created by this
- function will be destroyed automatically when their parent is destroyed.
+ Creates and returns a network access manager with the specified \a parent.
+ This method must return a new QNetworkAccessManager instance each time
+ it is called.
Note: this method may be called by multiple threads, so ensure the
implementation of this method is reentrant.