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 20, 2021
1 parent 95c01cc commit 3420e8a282af95ee86ec749677d7ae9ab4d24f03
Showing with 9 additions and 1 deletion.
  1. +2 −1 src/providers/wms/qgswmscapabilities.cpp
  2. +7 −0 tests/src/providers/testqgswmsprovider.cpp
@@ -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();
@@ -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;

0 comments on commit 3420e8a

Please sign in to comment.