Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[wms] Do not pass null QStrings to QgsWmsProvider::setQueryItem
Fix #20271 - WMS is not displayed in QGIS 3.4.0

With test
  • Loading branch information
elpaso committed Oct 31, 2018
1 parent 2f1dec9 commit 94aa628
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -482,7 +482,10 @@ bool QgsWmsProvider::setImageCrs( QString const &crs )
void QgsWmsProvider::setQueryItem( QUrl &url, const QString &item, const QString &value )
{
url.removeQueryItem( item );
url.addQueryItem( item, value );
if ( value.isNull() )
url.addQueryItem( item, QStringLiteral( "" ) );
else
url.addQueryItem( item, value );
}

void QgsWmsProvider::setFormatQueryItem( QUrl &url )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Expand Up @@ -461,6 +461,9 @@ class QgsWmsProvider : public QgsRasterDataProvider

//! User's settings (URI, authorization, layer, style, ...)
QgsWmsSettings mSettings;

friend class TestQgsWmsProvider;

};


Expand Down
11 changes: 11 additions & 0 deletions tests/src/providers/testqgswmsprovider.cpp
Expand Up @@ -76,6 +76,17 @@ class TestQgsWmsProvider: public QObject
QCOMPARE( provider.getLegendGraphicUrl(), QString( "http://localhost:8380/mapserv?" ) );
}

// regression #20271 - WMS is not displayed in QGIS 3.4.0
void queryItemsWithNullValue()
{
QString failingAddress( "http://localhost:8380/mapserv" );
QgsWmsProvider provider( failingAddress, QgsDataProvider::ProviderOptions(), mCapabilities );
QUrl url( provider.createRequestUrlWMS( QgsRectangle( 0, 0, 90, 90 ), 100, 100 ) );
QCOMPARE( url.toString(), QString( "http://localhost:8380/mapserv?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap"
"&BBOX=0,0,90,90&CRS=CRS:84&WIDTH=100&HEIGHT=100&LAYERS=&"
"STYLES=&FORMAT=&TRANSPARENT=TRUE" ) );
}

private:
QgsWmsCapabilities *mCapabilities = nullptr;
};
Expand Down

0 comments on commit 94aa628

Please sign in to comment.