From: Vadim Zeitlin Date: Fri, 31 May 2013 23:20:48 +0000 (+0000) Subject: Fix assert when adding columns to wxGrid using native header. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a2d65663a0e7e5d4633119bf469fe66d8a8897c5?ds=inline Fix assert when adding columns to wxGrid using native header. Change the order of updating m_colWidths array and the native header control in wxGird::Redimension() to ensure that we can test whether the column is shown (which results in accessing m_colWidths element at this column index) from the wxGridHeaderCtrl::SetColumnCount(). Closes #15225. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 4926ae4a99..751dc61143 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2945,8 +2945,6 @@ bool wxGrid::Redimension( wxGridTableMessage& msg ) int numCols = msg.GetCommandInt(); int oldNumCols = m_numCols; m_numCols += numCols; - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); if ( !m_colAt.IsEmpty() ) { @@ -2978,6 +2976,12 @@ bool wxGrid::Redimension( wxGridTableMessage& msg ) } } + // Notice that this must be called after updating m_colWidths above + // as the native grid control will check whether the new columns + // are shown which results in accessing m_colWidths array. + if ( m_useNativeHeader ) + GetGridColHeader()->SetColumnCount(m_numCols); + if ( m_currentCellCoords == wxGridNoCellCoords ) { // if we have just inserted cols into an empty grid the current