@@ -155,30 +155,34 @@ void QgsStatisticalSummaryDockWidget::refreshStatistics()
155
155
if ( ok )
156
156
{
157
157
int featureCount = selectedOnly ? mLayer ->selectedFeatureCount () : mLayer ->featureCount ();
158
- mGatherer = new QgsStatisticsValueGatherer ( mLayer , fit, featureCount, sourceFieldExp );
158
+ std::unique_ptr< QgsStatisticsValueGatherer > gatherer = qgis::make_unique< QgsStatisticsValueGatherer > ( mLayer , fit, featureCount, sourceFieldExp );
159
159
switch ( mFieldType )
160
160
{
161
161
case DataType::Numeric:
162
- connect ( mGatherer , &QgsStatisticsValueGatherer::taskCompleted, this , &QgsStatisticalSummaryDockWidget::updateNumericStatistics );
162
+ connect ( gatherer. get () , &QgsStatisticsValueGatherer::taskCompleted, this , &QgsStatisticalSummaryDockWidget::updateNumericStatistics );
163
163
break ;
164
164
case DataType::String:
165
- connect ( mGatherer , &QgsStatisticsValueGatherer::taskCompleted, this , &QgsStatisticalSummaryDockWidget::updateStringStatistics );
165
+ connect ( gatherer. get () , &QgsStatisticsValueGatherer::taskCompleted, this , &QgsStatisticalSummaryDockWidget::updateStringStatistics );
166
166
break ;
167
167
case DataType::DateTime:
168
- connect ( mGatherer , &QgsStatisticsValueGatherer::taskCompleted, this , &QgsStatisticalSummaryDockWidget::updateDateTimeStatistics );
168
+ connect ( gatherer. get () , &QgsStatisticsValueGatherer::taskCompleted, this , &QgsStatisticalSummaryDockWidget::updateDateTimeStatistics );
169
169
break ;
170
170
default :
171
- break ;
171
+ // don't know how to handle stats for this field!
172
+ mStatisticsTable ->setRowCount ( 0 );
173
+ return ;
172
174
}
173
- connect ( mGatherer , &QgsStatisticsValueGatherer::progressChanged, mCalculatingProgressBar , &QProgressBar::setValue );
174
- connect ( mCancelButton , &QPushButton::clicked, mGatherer , &QgsStatisticsValueGatherer::cancel );
175
+ connect ( gatherer.get (), &QgsStatisticsValueGatherer::progressChanged, mCalculatingProgressBar , &QProgressBar::setValue );
176
+ connect ( gatherer.get (), &QgsStatisticsValueGatherer::taskTerminated, this , &QgsStatisticalSummaryDockWidget::gathererFinished );
177
+ connect ( mCancelButton , &QPushButton::clicked, gatherer.get (), &QgsStatisticsValueGatherer::cancel );
175
178
mCalculatingProgressBar ->setMinimum ( 0 );
176
179
mCalculatingProgressBar ->setMaximum ( featureCount > 0 ? 100 : 0 );
177
180
mCalculatingProgressBar ->setValue ( 0 );
178
181
mCancelButton ->show ();
179
182
mCalculatingProgressBar ->show ();
180
183
181
- QgsApplication::taskManager ()->addTask ( mGatherer );
184
+ mGatherer = gatherer.get ();
185
+ QgsApplication::taskManager ()->addTask ( gatherer.release () );
182
186
}
183
187
}
184
188
0 commit comments