From 0e2d9e539c7c8f3f4f9e7b300d30e8d2958c733c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 19 Mar 2015 16:38:36 +0100 Subject: [PATCH] Fix wxGenericListCtrl autosizing after deleting all its items. Set bNeedsUpdate flag for all columns even when the control is already empty, this ensures that things will work if more items are added to it later. See #10326. --- src/generic/listctrl.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index c040bc657f..b02d3207c4 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4070,6 +4070,13 @@ void wxListMainWindow::DeleteColumn( int col ) void wxListMainWindow::DoDeleteAllItems() { + // We will need to update all columns if any items are inserted again. + if ( InReportView() ) + { + for ( size_t i = 0; i < m_aColWidths.GetCount(); i++ ) + m_aColWidths.Item(i)->bNeedsUpdate = true; + } + if ( IsEmpty() ) // nothing to do - in particular, don't send the event return; @@ -4092,13 +4099,7 @@ void wxListMainWindow::DoDeleteAllItems() } if ( InReportView() ) - { ResetVisibleLinesRange(); - for (size_t i = 0; i < m_aColWidths.GetCount(); i++) - { - m_aColWidths.Item(i)->bNeedsUpdate = true; - } - } m_lines.Clear(); }