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

Network cache not queried if network is disabled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.6.0
    • Network: Cache
    • None
    • Qt 5.6 on iOS 9.2, Windows 8 and Android
    • iOS/tvOS/watchOS

    Description

      When doing a network request with Qt 5.6 and networking is disabled in the device (eg. I turned off WiFi) the network cache is not queried and requests always fail. If network is enabled, requests query the cache as normal.

      class NetworkAccessManagerFactory: public QQmlNetworkAccessManagerFactory
      {
      public:
          QNetworkAccessManager *create(QObject *parent)
          {
              QNetworkAccessManager *manager = new QNetworkAccessManager(parent);
      
              QNetworkDiskCache *diskCache = new QNetworkDiskCache(manager);
              diskCache->setCacheDirectory(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).value(0));
              diskCache->setMaximumCacheSize(150 * 1024 * 1024); // 150 MiB
              manager->setCache(diskCache);
      
              return manager;
          }
      };

      It seems the following line in qnetworkaccessmanager.cpp:1169 is responsible:

      if (d->networkAccessible == NotAccessible && !isLocalFile) {
          return new QDisabledNetworkReply(this, req, op);
      }

      I get the Network access is disabled error message for all requests, both C++ and loading eg. an Image in QML.

      This used to work in Qt 5.5.

      Attachments

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

        Activity

          People

            richmoore Richard Moore (qtnetwork)
            broulik Kai Uwe Broulik
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes