Make sure there is a current row before comparing its position

This commit is contained in:
Paul Cornett
2021-12-30 17:11:51 -08:00
parent 21c3f10e28
commit 1be048fc53

View File

@@ -3277,7 +3277,7 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
} }
// Change the current row to the last row if the current exceed the max row number // Change the current row to the last row if the current exceed the max row number
if ( m_currentRow >= GetRowCount() ) if ( HasCurrentRow() && m_currentRow >= GetRowCount() )
ChangeCurrentRow(m_count - 1); ChangeCurrentRow(m_count - 1);
GetOwner()->InvalidateColBestWidths(); GetOwner()->InvalidateColBestWidths();
@@ -3974,7 +3974,7 @@ wxDataViewMainWindow::DoExpand(wxDataViewTreeNode* node,
// Shift all stored indices after this row by the number of newly added // Shift all stored indices after this row by the number of newly added
// rows. // rows.
m_selection.OnItemsInserted(row + 1, countNewRows); m_selection.OnItemsInserted(row + 1, countNewRows);
if ( m_currentRow > row ) if ( HasCurrentRow() && m_currentRow > row )
ChangeCurrentRow(m_currentRow + countNewRows); ChangeCurrentRow(m_currentRow + countNewRows);
if ( m_count != -1 ) if ( m_count != -1 )
@@ -4049,7 +4049,7 @@ void wxDataViewMainWindow::Collapse(unsigned int row)
node->ToggleOpen(this); node->ToggleOpen(this);
// Adjust the current row if necessary. // Adjust the current row if necessary.
if ( m_currentRow > row ) if ( HasCurrentRow() && m_currentRow > row )
{ {
// If the current row was among the collapsed items, make the // If the current row was among the collapsed items, make the
// parent itself current. // parent itself current.