Skip to content

Commit

Permalink
[WMS provider] Fix crash on WMS-T layer uri without timeDimensionExtent
Browse files Browse the repository at this point in the history
Fixes #43158
  • Loading branch information
rouault authored and nyalldawson committed May 25, 2021
1 parent e7aa39e commit 06bc4be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions tests/src/providers/testqgswmsprovider.cpp
Expand Up @@ -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;

Expand Down

0 comments on commit 06bc4be

Please sign in to comment.