Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a check for nullptr on mGatherer in QgsFeatureFilterModel::update…
…Completer.

Also avoid relying on signal to slot call order conservation to make sure that gathererThreadFinished is called after updateCompleter :
  - gathererThreadFinished is disconnected from finished signal emitted at the end of QgsFieldExpressionValuesGatherer::run
  - gathererThreadFinished is instead called explicitly at the end of updateCompleter
  - when QgsFieldExpressionValuesGatherer::run is stopped manually, rely on the connection to QgsFieldExpressionValuesGatherer::deleteLater to clean mGatherer.

This should fix an observed bug where a crash happened at the begining of updateCompleter because mGatherer was null.
  • Loading branch information
obrix authored and 3nids committed Mar 25, 2020
1 parent bcd0585 commit 90e148c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/qgsfeaturefiltermodel.cpp
Expand Up @@ -225,6 +225,12 @@ QVariant QgsFeatureFilterModel::data( const QModelIndex &index, int role ) const
void QgsFeatureFilterModel::updateCompleter()
{
emit beginUpdate();
if( !mGatherer )
{
emit endUpdate();
return;
}

QVector<Entry> entries = mGatherer->entries();

if ( mExtraIdentifierValueIndex == -1 )
Expand Down Expand Up @@ -341,6 +347,8 @@ void QgsFeatureFilterModel::updateCompleter()
emit filterJobCompleted();
}
emit endUpdate();

gathererThreadFinished();
}

void QgsFeatureFilterModel::gathererThreadFinished()
Expand All @@ -362,7 +370,6 @@ void QgsFeatureFilterModel::scheduledReload()
// Send the gatherer thread to the graveyard:
// forget about it, tell it to stop and delete when finished
disconnect( mGatherer, &QgsFieldExpressionValuesGatherer::collectedValues, this, &QgsFeatureFilterModel::updateCompleter );
disconnect( mGatherer, &QgsFieldExpressionValuesGatherer::finished, this, &QgsFeatureFilterModel::gathererThreadFinished );
connect( mGatherer, &QgsFieldExpressionValuesGatherer::finished, mGatherer, &QgsFieldExpressionValuesGatherer::deleteLater );
mGatherer->stop();
wasLoading = true;
Expand Down Expand Up @@ -414,7 +421,6 @@ void QgsFeatureFilterModel::scheduledReload()
mGatherer->setData( mShouldReloadCurrentFeature );

connect( mGatherer, &QgsFieldExpressionValuesGatherer::collectedValues, this, &QgsFeatureFilterModel::updateCompleter );
connect( mGatherer, &QgsFieldExpressionValuesGatherer::finished, this, &QgsFeatureFilterModel::gathererThreadFinished );

mGatherer->start();
if ( !wasLoading )
Expand Down

0 comments on commit 90e148c

Please sign in to comment.