Skip to content
Permalink
Browse files

[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 94aa628e3e94e5998ba762810e19be104c0f820b
@@ -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 )
@@ -461,6 +461,9 @@ class QgsWmsProvider : public QgsRasterDataProvider

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

friend class TestQgsWmsProvider;

};


@@ -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;
};

0 comments on commit 94aa628

Please sign in to comment.
You can’t perform that action at this time.