Skip to content

Commit 9a8c07e

Browse files
authored
Merge pull request #5296 from boundlessgeo/bugfix_16427_backport
[bugfix][backport] Do not cache invalid WM(T)S responses
2 parents f14502e + b09fb37 commit 9a8c07e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/providers/wms/qgstilecache.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ void QgsTileCache::insertTile( const QUrl& url, const QImage& image )
3333
bool QgsTileCache::tile( const QUrl& url, QImage& image )
3434
{
3535
QMutexLocker locker( &sTileCacheMutex );
36-
if ( QImage* i = sTileCache.object( url ) )
36+
bool success = false;
37+
if ( QImage *i = sTileCache.object( url ) )
3738
{
3839
image = *i;
39-
return true;
40+
success = true;
4041
}
4142
else if ( QgsNetworkAccessManager::instance()->cache()->metaData( url ).isValid() )
4243
{
@@ -48,10 +49,13 @@ bool QgsTileCache::tile( const QUrl& url, QImage& image )
4849
image = QImage::fromData( imageData );
4950

5051
// cache it as well (mutex is already locked)
51-
sTileCache.insert( url, new QImage( image ) );
52-
53-
return true;
52+
// Check for null because it could be a redirect (see: https://issues.qgis.org/issues/16427 )
53+
if ( ! image.isNull( ) )
54+
{
55+
sTileCache.insert( url, new QImage( image ) );
56+
success = true;
57+
}
5458
}
5559
}
56-
return false;
60+
return success;
5761
}

0 commit comments

Comments
 (0)