From d89af4e3116932b9c68f584bd8a1fa31d059bfe7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 7 Sep 2021 19:44:02 +0200 Subject: [PATCH] Fix regression with spurious generic wxListCtrl columns resizing Don't set default width every time the column is updated, as it happens e.g. when it's clicked by the user, but only when it is created, by moving the code added in 96d36383bd (Use sensible default column width in generic wxListCtrl too, 2021-08-17) from SetItem() to the ctor of wxListHeaderData. Closes #19256. --- src/generic/listctrl.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 974def6d83..5d8023f6b3 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -298,6 +298,11 @@ wxListHeaderData::wxListHeaderData( const wxListItem &item ) Init(); SetItem( item ); + + // Always give some initial width to the new columns (it's still possible + // to set the width to 0 explicitly, however). + if ( !(m_mask & wxLIST_MASK_WIDTH) ) + SetWidth(wxLIST_DEFAULT_COL_WIDTH); } void wxListHeaderData::SetItem( const wxListItem &item ) @@ -313,9 +318,8 @@ void wxListHeaderData::SetItem( const wxListItem &item ) if ( m_mask & wxLIST_MASK_FORMAT ) m_format = item.m_format; - // Always give some initial width to the new columns (it's still possible - // to set the width to 0 explicitly, however). - SetWidth(m_mask & wxLIST_MASK_WIDTH ? item.m_width : wxLIST_DEFAULT_COL_WIDTH); + if ( m_mask & wxLIST_MASK_WIDTH ) + SetWidth(item.m_width); if ( m_mask & wxLIST_MASK_STATE ) SetState(item.m_state);