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

Network cache not queried if network is disabled

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P1: Critical
    • Resolution: Unresolved
    • Affects Version/s: 5.6.0
    • Fix Version/s: None
    • Component/s: Network: Cache
    • Labels:
      None
    • Environment:
      Qt 5.6 on iOS 9.2, Windows 8 and Android

      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

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

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes