]> git.saurik.com Git - wxWidgets.git/commitdiff
fix crash when calling InsertColumn() on a wxListCtrl with wxLC_NO_HEADER style
authorFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Tue, 27 Jan 2009 12:05:27 +0000 (12:05 +0000)
committerFrancesco Montorsi <f18m_cpp217828@yahoo.it>
Tue, 27 Jan 2009 12:05:27 +0000 (12:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/listctrl.cpp

index 837a2900445a771d20615fabd025697d2b3bd2f0..a0a2e38abae791e7d7634aad61dab4e01badaf22 100644 (file)
@@ -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;
 }