Skip to content

Commit

Permalink
Fix crash when disabling defined sort order in attribute table
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed Jun 16, 2020
1 parent 300fc9e commit 05f4359
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/gui/attributetable/qgsattributetablefiltermodel.cpp
Expand Up @@ -78,10 +78,16 @@ void QgsAttributeTableFilterModel::sort( int column, Qt::SortOrder order )
{
if ( order != Qt::AscendingOrder && order != Qt::DescendingOrder )
order = Qt::AscendingOrder;

int myColumn = mColumnMapping.at( column );
masterModel()->prefetchColumnData( myColumn );
QSortFilterProxyModel::sort( myColumn, order );
if ( column < 0 || column >= mColumnMapping.size() )
{
sort( QString() );
}
else
{
int myColumn = mColumnMapping.at( column );
masterModel()->prefetchColumnData( myColumn );
QSortFilterProxyModel::sort( myColumn, order );
}
emit sortColumnChanged( column, order );
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/attributetable/qgsattributetableview.cpp
Expand Up @@ -108,6 +108,8 @@ void QgsAttributeTableView::setAttributeTableConfig( const QgsAttributeTableConf
i++;
}
mConfig = config;
if ( config.sortExpression().isEmpty() )
horizontalHeader()->setSortIndicatorShown( false );
}

QList<QgsFeatureId> QgsAttributeTableView::selectedFeaturesIds() const
Expand Down

0 comments on commit 05f4359

Please sign in to comment.