Skip to content

Commit 149ab30

Browse files
committed
[Geometry checker] Delay sorting of results until all are listed
1 parent 27c5f78 commit 149ab30

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/plugins/geometry_checker/ui/qgsgeometrycheckerdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void QgsGeometryCheckerDialog::onCheckerFinished( bool successful )
7070
{
7171
mTabWidget->setTabEnabled( 1, true );
7272
mTabWidget->setCurrentIndex( 1 );
73-
static_cast<QgsGeometryCheckerResultTab*>( mTabWidget->widget( 1 ) )->showCheckMessages();
73+
static_cast<QgsGeometryCheckerResultTab*>( mTabWidget->widget( 1 ) )->finalize();
7474
}
7575
}
7676

src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface* iface,
7676

7777
ui.progressBarFixErrors->setVisible( false );
7878
ui.tableWidgetErrors->horizontalHeader()->setSortIndicator( 0, Qt::AscendingOrder );
79+
// Not sure why, but this is needed...
7980
ui.tableWidgetErrors->setSortingEnabled( true );
81+
ui.tableWidgetErrors->setSortingEnabled( false );
8082
}
8183

8284
QgsGeometryCheckerResultTab::~QgsGeometryCheckerResultTab()
@@ -88,8 +90,9 @@ QgsGeometryCheckerResultTab::~QgsGeometryCheckerResultTab()
8890
qDeleteAll( mCurrentRubberBands );
8991
}
9092

91-
void QgsGeometryCheckerResultTab::showCheckMessages()
93+
void QgsGeometryCheckerResultTab::finalize()
9294
{
95+
ui.tableWidgetErrors->setSortingEnabled( true );
9396
if ( !mChecker->getMessages().isEmpty() )
9497
{
9598
QDialog dialog;
@@ -107,11 +110,6 @@ void QgsGeometryCheckerResultTab::showCheckMessages()
107110

108111
void QgsGeometryCheckerResultTab::addError( QgsGeometryCheckError *error )
109112
{
110-
// Disable sorting to prevent crashes: if i.e. sorting by col 0, as soon as the item(row, 0)
111-
// is set, the row is potentially moved due to sorting, and subsequent item(row, col) reference wrong
112-
// item
113-
ui.tableWidgetErrors->setSortingEnabled( false );
114-
115113
int row = ui.tableWidgetErrors->rowCount();
116114
int prec = 7 - std::floor( qMax( 0., std::log10( qMax( error->location().x(), error->location().y() ) ) ) );
117115
QString posStr = QString( "%1, %2" ).arg( error->location().x(), 0, 'f', prec ).arg( error->location().y(), 0, 'f', prec );
@@ -144,8 +142,6 @@ void QgsGeometryCheckerResultTab::addError( QgsGeometryCheckError *error )
144142
ui.labelErrorCount->setText( tr( "Total errors: %1, fixed errors: %2" ).arg( mErrorCount ).arg( mFixedCount ) );
145143
mStatistics.newErrors.insert( error );
146144
mErrorMap.insert( error, QPersistentModelIndex( ui.tableWidgetErrors->model()->index( row, 0 ) ) );
147-
148-
ui.tableWidgetErrors->setSortingEnabled( true );
149145
}
150146

151147
void QgsGeometryCheckerResultTab::updateError( QgsGeometryCheckError *error, bool statusChanged )

src/plugins/geometry_checker/ui/qgsgeometrycheckerresulttab.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QgsGeometryCheckerResultTab : public QWidget
3434
public:
3535
QgsGeometryCheckerResultTab( QgisInterface* iface, QgsGeometryChecker* checker, QgsFeaturePool *featurePool, QTabWidget *tabWidget, QWidget* parent = nullptr );
3636
~QgsGeometryCheckerResultTab();
37-
void showCheckMessages();
37+
void finalize();
3838
bool isCloseable() const { return mCloseable; }
3939

4040
static QString sSettingsGroup;

0 commit comments

Comments
 (0)