Fix asserts when changing columns of wxGrid using native header
The number of columns has to be changed after updating the m_colAt and
m_colWidths arrays, as the native header uses them.
This extends the changes of a2d65663a0 (Fix assert when adding columns
to wxGrid using native header., 2013-05-31) to inserting and deleting
the columns too.
See #15225.
Closes #22294.
This commit is contained in:
committed by
Vadim Zeitlin
parent
7e34e9f572
commit
7f8f2a9aa3
@@ -3473,9 +3473,6 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
|
||||
int numCols = msg.GetCommandInt2();
|
||||
m_numCols += numCols;
|
||||
|
||||
if ( m_useNativeHeader )
|
||||
GetGridColHeader()->SetColumnCount(m_numCols);
|
||||
|
||||
if ( !m_colAt.IsEmpty() )
|
||||
{
|
||||
//Shift the column IDs
|
||||
@@ -3513,6 +3510,11 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
|
||||
}
|
||||
}
|
||||
|
||||
// See comment for wxGRIDTABLE_NOTIFY_COLS_APPENDED case explaining
|
||||
// why this has to be done here and not before.
|
||||
if ( m_useNativeHeader )
|
||||
GetGridColHeader()->SetColumnCount(m_numCols);
|
||||
|
||||
UpdateCurrentCellOnRedim();
|
||||
|
||||
if ( m_selection )
|
||||
@@ -3586,8 +3588,6 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
|
||||
size_t pos = msg.GetCommandInt();
|
||||
int numCols = msg.GetCommandInt2();
|
||||
m_numCols -= numCols;
|
||||
if ( m_useNativeHeader )
|
||||
GetGridColHeader()->SetColumnCount(m_numCols);
|
||||
|
||||
if ( !m_colAt.IsEmpty() )
|
||||
{
|
||||
@@ -3620,6 +3620,11 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
|
||||
}
|
||||
}
|
||||
|
||||
// See comment for wxGRIDTABLE_NOTIFY_COLS_APPENDED case explaining
|
||||
// why this has to be done here and not before.
|
||||
if ( m_useNativeHeader )
|
||||
GetGridColHeader()->SetColumnCount(m_numCols);
|
||||
|
||||
UpdateCurrentCellOnRedim();
|
||||
|
||||
if ( m_selection )
|
||||
|
||||
Reference in New Issue
Block a user