Skip to content

Commit

Permalink
Merge pull request #8388 from elpaso/bugfix-20271-wms-null-styles
Browse files Browse the repository at this point in the history
[wms] Do not pass null QStrings to QgsWmsProvider::setQueryItem
  • Loading branch information
elpaso committed Oct 31, 2018
2 parents b64e72a + 9f2fb2d commit 467fae8
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
Original file line number Diff line number Diff line change
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( "" ) ); // skip-keyword-check
else
url.addQueryItem( item, value );
}

void QgsWmsProvider::setFormatQueryItem( QUrl &url )
Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 467fae8

Please sign in to comment.