Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #5296 from boundlessgeo/bugfix_16427_backport
[bugfix][backport] Do not cache invalid WM(T)S responses
- Loading branch information
Showing
with
10 additions
and
6 deletions.
-
+10
−6
src/providers/wms/qgstilecache.cpp
|
@@ -33,10 +33,11 @@ void QgsTileCache::insertTile( const QUrl& url, const QImage& image ) |
|
|
bool QgsTileCache::tile( const QUrl& url, QImage& image ) |
|
|
{ |
|
|
QMutexLocker locker( &sTileCacheMutex ); |
|
|
if ( QImage* i = sTileCache.object( url ) ) |
|
|
bool success = false; |
|
|
if ( QImage *i = sTileCache.object( url ) ) |
|
|
{ |
|
|
image = *i; |
|
|
return true; |
|
|
success = true; |
|
|
} |
|
|
else if ( QgsNetworkAccessManager::instance()->cache()->metaData( url ).isValid() ) |
|
|
{ |
|
@@ -48,10 +49,13 @@ bool QgsTileCache::tile( const QUrl& url, QImage& image ) |
|
|
image = QImage::fromData( imageData ); |
|
|
|
|
|
// cache it as well (mutex is already locked) |
|
|
sTileCache.insert( url, new QImage( image ) ); |
|
|
|
|
|
return true; |
|
|
// Check for null because it could be a redirect (see: https://issues.qgis.org/issues/16427 ) |
|
|
if ( ! image.isNull( ) ) |
|
|
{ |
|
|
sTileCache.insert( url, new QImage( image ) ); |
|
|
success = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return success; |
|
|
} |