From 5fe143dfdfa19c4fe8e15abfa933940fb51662e5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 20 Jul 2001 20:54:17 +0000 Subject: [PATCH] fix for rather mysterious problem when deleting the list ctrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11129 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/listctrl.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 8ea0eada4e..fa1cc35090 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -819,6 +819,9 @@ private: // initialize the current item if needed void UpdateCurrent(); + // delete all items but don't refresh: called from dtor + void DoDeleteAllItems(); + // called when an item is [un]focuded, i.e. becomes [not] current // // currently unused @@ -2159,7 +2162,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxListMainWindow::~wxListMainWindow() { - DeleteEverything(); + DoDeleteAllItems(); delete m_highlightBrush; @@ -3549,7 +3552,8 @@ void wxListMainWindow::SetItemCount(long count) ResetVisibleLinesRange(); - Refresh(); + // scrollbars must be reset + m_dirty = TRUE; } int wxListMainWindow::GetSelectedItemCount() @@ -3608,9 +3612,6 @@ bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) void wxListMainWindow::RecalculatePositions() { - if ( IsEmpty() ) - return; - wxClientDC dc( this ); dc.SetFont( GetFont() ); @@ -3839,7 +3840,7 @@ void wxListMainWindow::DeleteColumn( int col ) m_columns.DeleteNode( node ); } -void wxListMainWindow::DeleteAllItems() +void wxListMainWindow::DoDeleteAllItems() { if ( IsEmpty() ) { @@ -3871,11 +3872,13 @@ void wxListMainWindow::DeleteAllItems() } m_lines.Clear(); +} - // NB: don't just set m_dirty to TRUE here as RecalculatePositions() - // doesn't do anything if the control is empty and so we won't be - // refreshed - Refresh(); +void wxListMainWindow::DeleteAllItems() +{ + DoDeleteAllItems(); + + RecalculatePositions(); } void wxListMainWindow::DeleteEverything() -- 2.49.0