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
  • Loading branch information
rouault committed May 20, 2021
1 parent 50aa9d4 commit 4743ee5
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
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ bool QgsWmsSettings::parseUri( const QString &uriString )
mTemporalExtent = uri.param( QStringLiteral( "timeDimensionExtent" ) );
mTimeDimensionExtent = parseTemporalExtent( mTemporalExtent );

if ( !mTimeDimensionExtent.datesResolutionList.constFirst().dates.dateTimes.empty() )
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
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,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 4743ee5

Please sign in to comment.