Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-27723

QDeclarativeDataLoader should honor synchronous requests made via QNetworkAccessManager

    XMLWordPrintable

Details

    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peter-har Peter Hartmann
            peter-har Peter Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes