Skip to content
Permalink
Browse files

If layer changes in stats summary dock, reset field to empty

This prevents a stats gatherer task immediately firing off
on a random field. Otherwise if the current layer is removed
from the project, a new (random) layer will be selected
in the stats dock and a task will fire off gathering (unwanted)
stats for it. If multiple layers are removed this can trigger
many gatherers, all of which are unwanted.
  • Loading branch information
nyalldawson committed Jul 17, 2018
1 parent 77eafc0 commit a24c9e1ed0f37c332852a7fb5103fc5acca50670
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/app/qgsstatisticalsummarydockwidget.cpp
@@ -154,7 +154,7 @@ void QgsStatisticalSummaryDockWidget::copyStatistics()

void QgsStatisticalSummaryDockWidget::refreshStatistics()
{
if ( !mLayer || ( mFieldExpressionWidget->isExpression() && !mFieldExpressionWidget->isValidExpression() ) )
if ( !mLayer || mFieldExpressionWidget->currentField().isEmpty() || ( mFieldExpressionWidget->isExpression() && !mFieldExpressionWidget->isValidExpression() ) )
{
mStatisticsTable->setRowCount( 0 );
return;
@@ -346,13 +346,15 @@ void QgsStatisticalSummaryDockWidget::layerChanged( QgsMapLayer *layer )

mLayer = newLayer;

// clear expression, so that we don't force an unwanted recalculation
mFieldExpressionWidget->setExpression( QString() );
mFieldExpressionWidget->setLayer( mLayer );

if ( mLayer )
{
connect( mLayer, &QgsVectorLayer::selectionChanged, this, &QgsStatisticalSummaryDockWidget::layerSelectionChanged );
}

mFieldExpressionWidget->setLayer( mLayer );

if ( mGatherer )
{
mGatherer->cancel();

0 comments on commit a24c9e1

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