Skip to content

Commit 4bbce14

Browse files
committed
WMS: try to interpret response to map requests always as image (fixes #9197)
1 parent 8fabc4d commit 4bbce14

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

src/providers/wms/qgswmsprovider.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,24 +1389,22 @@ void QgsWmsProvider::cacheReplyFinished()
13891389

13901390
QString contentType = mCacheReply->header( QNetworkRequest::ContentTypeHeader ).toString();
13911391
QgsDebugMsg( "contentType: " + contentType );
1392-
if ( contentType.startsWith( "image/", Qt::CaseInsensitive ) ||
1393-
contentType.compare( "application/octet-stream", Qt::CaseInsensitive ) == 0 )
1392+
QByteArray text = mCacheReply->readAll();
1393+
QImage myLocalImage = QImage::fromData( text );
1394+
1395+
if ( !myLocalImage.isNull() )
13941396
{
1395-
QImage myLocalImage = QImage::fromData( mCacheReply->readAll() );
1396-
if ( !myLocalImage.isNull() )
1397-
{
1398-
QPainter p( mCachedImage );
1399-
p.drawImage( 0, 0, myLocalImage );
1400-
}
1401-
else
1402-
{
1403-
QgsMessageLog::logMessage( tr( "Returned image is flawed [Content-Type:%1; URL:%2]" )
1404-
.arg( contentType ).arg( mCacheReply->url().toString() ), tr( "WMS" ) );
1405-
}
1397+
QPainter p( mCachedImage );
1398+
p.drawImage( 0, 0, myLocalImage );
1399+
}
1400+
else if ( contentType.startsWith( "image/", Qt::CaseInsensitive ) ||
1401+
contentType.compare( "application/octet-stream", Qt::CaseInsensitive ) == 0 )
1402+
{
1403+
QgsMessageLog::logMessage( tr( "Returned image is flawed [Content-Type:%1; URL:%2]" )
1404+
.arg( contentType ).arg( mCacheReply->url().toString() ), tr( "WMS" ) );
14061405
}
14071406
else
14081407
{
1409-
QByteArray text = mCacheReply->readAll();
14101408
if ( contentType.toLower() == "text/xml" && parseServiceExceptionReportDom( text ) )
14111409
{
14121410
QgsMessageLog::logMessage( tr( "Map request error (Title:%1; Error:%2; URL: %3)" )
@@ -1421,17 +1419,12 @@ void QgsWmsProvider::cacheReplyFinished()
14211419
.arg( contentType )
14221420
.arg( mCacheReply->url().toString() ), tr( "WMS" ) );
14231421
}
1424-
1425-
mCacheReply->deleteLater();
1426-
mCacheReply = 0;
1427-
1428-
return;
14291422
}
14301423

14311424
mCacheReply->deleteLater();
14321425
mCacheReply = 0;
14331426

1434-
if ( !mWaiting )
1427+
if ( !mWaiting && !myLocalImage.isNull() )
14351428
{
14361429
QgsDebugMsg( "emit dataChanged()" );
14371430
emit dataChanged();

0 commit comments

Comments
 (0)