Skip to content
Permalink
Browse files
[WMS provider] Fix crash on WMS-T layer uri without timeDimensionExtent
Fixes #43158
  • Loading branch information
rouault authored and nyalldawson committed May 21, 2021
1 parent 3684c4c commit 8b70ff98a544d6f80acf4f75b6d959e7a6578002
Showing with 9 additions and 1 deletion.
  1. +2 −1 src/providers/wms/qgswmscapabilities.cpp
  2. +7 −0 tests/src/providers/testqgswmsprovider.cpp
@@ -88,7 +88,8 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
mTemporalExtent = uri.param( QStringLiteral( "timeDimensionExtent" ) );
mTimeDimensionExtent = parseTemporalExtent( mTemporalExtent );

if ( mTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.size() > 0 )
if ( !mTimeDimensionExtent.datesResolutionList.isEmpty() &&
!mTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.empty() )
{
QDateTime begin = mTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.first();
QDateTime end = mTimeDimensionExtent.datesResolutionList.constLast().dates.dateTimes.last();
@@ -230,6 +230,13 @@ class TestQgsWmsProvider: public QObject
return myResultFlag;
}

void testParseWmstUriWithoutTemporalExtent()
{
// test fix for https://github.com/qgis/QGIS/issues/43158
// we just check we don't crash
QgsWmsProvider provider( QStringLiteral( "allowTemporalUpdates=true&temporalSource=provider&type=wmst&layers=foostyles=bar&crs=EPSG:3857&format=image/png&url=file:///dummy" ), QgsDataProvider::ProviderOptions(), mCapabilities );
}

private:
QgsWmsCapabilities *mCapabilities = nullptr;

0 comments on commit 8b70ff9

Please sign in to comment.