From 014e8d6215b30cc724cd9c58ed12a36979078c18 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 2 Aug 2014 12:19:18 +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/branches/WX_3_0_BRANCH@76975 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 e292e452ba..f60841049d 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2359,12 +2359,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) {