Details
-
Type:
Bug
-
Status: Reported
-
Priority:
P2: Important
-
Resolution: Unresolved
-
Affects Version/s: 5.9.0 Beta 1
-
Fix Version/s: None
-
Component/s: Network: Cache, QML: Declarative and Javascript Engine
-
Labels:None
-
Environment:Ubuntu Linux 14.04 LTS
Description
If:
- a cache is specified for QNetworkAccessManager and
- PreferCache is specified using QNetworkRequest's method setAttribute called like
setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache) and
- the network/internet connection is not present
then, the request will still fail when called from a RichText QML Text with
QML QQuickText: Network access is disabled.
However, if you modify the setAttribute call to use QNetworkRequest::AlwaysCache when the network isn't present, then it will work:
cacheRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
(networkAccessible() == QNetworkAccessManager::Accessible ?
QNetworkRequest::PreferCache :
QNetworkRequest::AlwaysCache));
I would like to suggest that this is a bug, because if you say you would PreferCache, you don't want it to fail if you have a valid cache entry, but the network isn't present.
For more code context, see this StackOverflow answer by jpnurmi