Skip to content
Permalink
Browse files

Merge pull request #8388 from elpaso/bugfix-20271-wms-null-styles

[wms] Do not pass null QStrings to QgsWmsProvider::setQueryItem
  • Loading branch information
elpaso committed Oct 31, 2018
2 parents b64e72a + 9f2fb2d commit 467fae8e2601bf4f2a32661acbf54a74fbeb36ba
@@ -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( "" ) ); // skip-keyword-check
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 467fae8

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