Skip to content

Commit

Permalink
Fix potential crash on QGIS exit under rare circumstances
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Nov 4, 2020
1 parent c63b278 commit c662273
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/app/qgisapp.cpp
Expand Up @@ -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() );
}
}
}
}
Expand Down

0 comments on commit c662273

Please sign in to comment.