From 52d2a5e4541626d86a501e137eeccc38ade3a283 Mon Sep 17 00:00:00 2001 From: Francesco Montorsi Date: Tue, 27 Jan 2009 12:05:27 +0000 Subject: [PATCH] fix crash when calling InsertColumn() on a wxListCtrl with wxLC_NO_HEADER style git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listctrl.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 837a290044..a0a2e38aba 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4188,8 +4188,11 @@ void wxListMainWindow::OnScroll(wxScrollWinEvent& event) wxGenericListCtrl* lc = GetListCtrl(); wxCHECK_RET( lc, _T("no listctrl window?") ); - lc->m_headerWin->Refresh(); - lc->m_headerWin->Update(); + if (lc->m_headerWin) // when we use wxLC_NO_HEADER, m_headerWin==NULL + { + lc->m_headerWin->Refresh(); + lc->m_headerWin->Update(); + } } } @@ -4871,15 +4874,14 @@ long wxGenericListCtrl::InsertItem( long index, const wxString &label, int image long wxGenericListCtrl::InsertColumn( long col, wxListItem &item ) { - wxCHECK_MSG( m_headerWin, -1, _T("can't add column in non report mode") ); + wxCHECK_MSG( InReportView(), -1, _T("can't add column in non report mode") ); m_mainWin->InsertColumn( col, item ); - // if we hadn't had a header before but have one now - // then we need to relayout the window - // if ( GetColumnCount() == 1 && m_mainWin->HasHeader() ) - - m_headerWin->Refresh(); + // NOTE: if wxLC_NO_HEADER was given, then we are in report view mode but + // still have m_headerWin==NULL + if (m_headerWin) + m_headerWin->Refresh(); return 0; } -- 2.50.0