Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #5289 from boundlessgeo/bugfix_16427
[bugfix] Do not cache invalid WM(T)S responses
  • Loading branch information
elpaso committed Oct 3, 2017
2 parents 22d4d22 + afecc21 commit 9256d00
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/providers/wms/qgstilecache.cpp
Expand Up @@ -33,10 +33,11 @@ void QgsTileCache::insertTile( const QUrl &url, const QImage &image )
bool QgsTileCache::tile( const QUrl &url, QImage &image )
{
QMutexLocker locker( &sTileCacheMutex );
bool success = false;
if ( QImage *i = sTileCache.object( url ) )
{
image = *i;
return true;
success = true;
}
else if ( QgsNetworkAccessManager::instance()->cache()->metaData( url ).isValid() )
{
Expand All @@ -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;
}

0 comments on commit 9256d00

Please sign in to comment.