mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Thread safety for feature counter
Make sure that results from a feature counter will only be delivered on the main thread and that they will be discarded if the layer is deleted meanwhile.
This commit is contained in:
parent
b5bb7df7eb
commit
4ea4478bad
@ -1787,10 +1787,6 @@ Returns the current blending mode for features
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
|
||||
protected slots:
|
||||
void invalidateSymbolCountedFlag();
|
||||
|
||||
signals:
|
||||
|
||||
void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, const bool clearAndSelect );
|
||||
|
@ -770,8 +770,8 @@ bool QgsVectorLayer::countSymbolFeatures()
|
||||
if ( !mFeatureCounter )
|
||||
{
|
||||
mFeatureCounter = new QgsVectorLayerFeatureCounter( this );
|
||||
connect( mFeatureCounter, &QgsTask::taskCompleted, [ = ]() { onSymbolsCounted(); mFeatureCounter = nullptr; } );
|
||||
connect( mFeatureCounter, &QgsTask::taskTerminated, [ = ]() { mFeatureCounter = nullptr; } );
|
||||
connect( mFeatureCounter, &QgsTask::taskCompleted, this, &QgsVectorLayer::onFeatureCounterCompleted );
|
||||
connect( mFeatureCounter, &QgsTask::taskTerminated, this, &QgsVectorLayer::onFeatureCounterTerminated );
|
||||
|
||||
QgsApplication::taskManager()->addTask( mFeatureCounter );
|
||||
}
|
||||
@ -4034,6 +4034,17 @@ void QgsVectorLayer::invalidateSymbolCountedFlag()
|
||||
mSymbolFeatureCounted = false;
|
||||
}
|
||||
|
||||
void QgsVectorLayer::onFeatureCounterCompleted()
|
||||
{
|
||||
onSymbolsCounted();
|
||||
mFeatureCounter = nullptr;
|
||||
}
|
||||
|
||||
void QgsVectorLayer::onFeatureCounterTerminated()
|
||||
{
|
||||
mFeatureCounter = nullptr;
|
||||
}
|
||||
|
||||
void QgsVectorLayer::onJoinedFieldsChanged()
|
||||
{
|
||||
// some of the fields of joined layers have changed -> we need to update this layer's fields too
|
||||
|
@ -1662,10 +1662,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
*/
|
||||
bool startEditing();
|
||||
|
||||
|
||||
protected slots:
|
||||
void invalidateSymbolCountedFlag();
|
||||
|
||||
signals:
|
||||
|
||||
/**
|
||||
@ -1901,6 +1897,9 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
void symbolFeatureCountMapChanged();
|
||||
|
||||
private slots:
|
||||
void invalidateSymbolCountedFlag();
|
||||
void onFeatureCounterCompleted();
|
||||
void onFeatureCounterTerminated();
|
||||
void onJoinedFieldsChanged();
|
||||
void onFeatureDeleted( QgsFeatureId fid );
|
||||
void onRelationsLoaded();
|
||||
|
Loading…
x
Reference in New Issue
Block a user