Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.8.3
-
qtquick1: e5783b79887299d094e6976630373a4899bd7074, 4.8: c370a6c7fe1965157fa47380bfe7fb4da5eae96b
Description
network requests made via e.g. QNetworkAccessManager::get() can be synchronous or asynchronous. QDeclarativeLoader could honor this by checking whether the reply is finished or not, somehow like this:
diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp index b92883e..f0bbced 100644 --- a/src/declarative/qml/qdeclarativetypeloader.cpp +++ b/src/declarative/qml/qdeclarativetypeloader.cpp @@ -552,10 +552,14 @@ void QDeclarativeDataLoader::load(QDeclarativeDataBlob *blob) blob->m_manager = this; QNetworkReply *reply = m_engine->networkAccessManager()->get(QNetworkRequest(blob->m_url)); - QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(networkReplyProgress(qint64,qint64))); - QObject::connect(reply, SIGNAL(finished()), - this, SLOT(networkReplyFinished())); + if (reply->isFinished()) { + // ### here set state to finished etc. + } else { + QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), + this, SLOT(networkReplyProgress(qint64,qint64))); + QObject::connect(reply, SIGNAL(finished()), + this, SLOT(networkReplyFinished())); + } m_networkReplies.insert(reply, blob); blob->addref();
Then it would not need to go into loading state when the reply has finished already.
This is useful when implementing an own (custom) synchronous scheme in QNetworkAccessManager.
Attachments
For Gerrit Dashboard: QTBUG-27723 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
40718,4 | QML file loading: honor synchronous requests made through QNAM | master | qt/qtquick1 | Status: MERGED | +2 | 0 |
40741,2 | QML file loading: honor synchronous requests made through QNAM | 4.8 | qt/qt | Status: ABANDONED | -1 | 0 |
49396,5 | Work with synchronous replies from a custom QNetworkAccessManager | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |