Skip to content
Permalink
Browse files

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 Feb 19, 2020
1 parent bcd0585 commit 90e148c95d2202e43be699bdf9dda1367086a26e
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/core/qgsfeaturefiltermodel.cpp
@@ -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 )
@@ -341,6 +347,8 @@ void QgsFeatureFilterModel::updateCompleter()
emit filterJobCompleted();
}
emit endUpdate();

gathererThreadFinished();
}

void QgsFeatureFilterModel::gathererThreadFinished()
@@ -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;
@@ -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 )

0 comments on commit 90e148c

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