Skip to content
Permalink
Browse files

Fix potential crash on QGIS exit under rare circumstances

  • Loading branch information
github-actions authored and nyalldawson committed Nov 4, 2020
1 parent c63b278 commit c6622732c65b018c866e8af9ff1337e5c48cf907
Showing with 14 additions and 13 deletions.
  1. +14 −13 src/app/qgisapp.cpp
@@ -11462,23 +11462,24 @@ void QgisApp::projectTemporalRangeChanged()

if ( currentLayer->dataProvider() )
{
QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata(
currentLayer->providerType() );

QVariantMap uri = metadata->decodeUri( currentLayer->dataProvider()->dataSourceUri() );

if ( uri.contains( QStringLiteral( "temporalSource" ) ) &&
uri.value( QStringLiteral( "temporalSource" ) ).toString() == QLatin1String( "project" ) )
if ( QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata(
currentLayer->providerType() ) )
{
QgsDateTimeRange range = QgsProject::instance()->timeSettings()->temporalRange();
if ( range.begin().isValid() && range.end().isValid() )
QVariantMap uri = metadata->decodeUri( currentLayer->dataProvider()->dataSourceUri() );

if ( uri.contains( QStringLiteral( "temporalSource" ) ) &&
uri.value( QStringLiteral( "temporalSource" ) ).toString() == QLatin1String( "project" ) )
{
QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' +
range.end().toString( Qt::ISODateWithMs );
QgsDateTimeRange range = QgsProject::instance()->timeSettings()->temporalRange();
if ( range.begin().isValid() && range.end().isValid() )
{
QString time = range.begin().toString( Qt::ISODateWithMs ) + '/' +
range.end().toString( Qt::ISODateWithMs );

uri[ QStringLiteral( "time" ) ] = time;
uri[ QStringLiteral( "time" ) ] = time;

currentLayer->setDataSource( metadata->encodeUri( uri ), currentLayer->name(), currentLayer->providerType(), QgsDataProvider::ProviderOptions() );
currentLayer->setDataSource( metadata->encodeUri( uri ), currentLayer->name(), currentLayer->providerType(), QgsDataProvider::ProviderOptions() );
}
}
}
}

0 comments on commit c662273

Please sign in to comment.
You can’t perform that action at this time.