From 220a8d1ac297e3bbc13c8cacbf5e2c0499df3a3a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 2 Aug 2014 12:19:34 +0000 Subject: [PATCH] Correct wxGrid column labels when using SetTable() with native header. Ensure that the table pointer inside wxGrid is updated before initializing the native column header as it uses wxGrid::GetColLabelValue() which doesn't work correctly without a valid table pointer. Closes #16399. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/grid.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 17cae6e47e..45c34892dd 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2347,12 +2347,15 @@ wxGrid::SetTable(wxGridTableBase *table, m_numRows = table->GetNumberRows(); m_numCols = table->GetNumberCols(); - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - m_table = table; m_table->SetView( this ); m_ownTable = takeOwnership; + + // Notice that this must be called after setting m_table as it uses it + // indirectly, via wxGrid::GetColLabelValue(). + if ( m_useNativeHeader ) + GetGridColHeader()->SetColumnCount(m_numCols); + m_selection = new wxGridSelection( this, selmode ); if (checkSelection) {