From 6f59c756f6f1e4b5d7bba429d3f1d0acc6473e42 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 30 Apr 2017 21:42:41 +0200 Subject: [PATCH] Fix inserting items to wxRearrangeList (wxGTK) Order array cannot be extended both in DoInsertItems() and DoInsertOneItem() functions because DoInsertOneItem() is invoked indirectly from DoInsertItems() (through the call to wxCheckListBox::DoInsertItems() and DoInsertItemsInLoop()) and therefore order array would be eventually extended by two items for one inserted list item. To avoid this duplicated actions, we should resign from overriding DoInsertOneItem(). --- include/wx/rearrangectrl.h | 1 - src/common/rearrangectrl.cpp | 9 --------- 2 files changed, 10 deletions(-) diff --git a/include/wx/rearrangectrl.h b/include/wx/rearrangectrl.h index beb45df2fe..06d8e58968 100644 --- a/include/wx/rearrangectrl.h +++ b/include/wx/rearrangectrl.h @@ -99,7 +99,6 @@ public: // Override this to keep our m_order array in sync with the real item state. virtual void Check(unsigned int item, bool check = true) wxOVERRIDE; - int DoInsertOneItem(const wxString& item, unsigned int pos) wxOVERRIDE; int DoInsertItems(const wxArrayStringsAdapter& items, unsigned int pos, void **clientData, wxClientDataType type) wxOVERRIDE; void DoDeleteOneItem(unsigned int n) wxOVERRIDE; diff --git a/src/common/rearrangectrl.cpp b/src/common/rearrangectrl.cpp index 53795c950f..75170d35dc 100644 --- a/src/common/rearrangectrl.cpp +++ b/src/common/rearrangectrl.cpp @@ -188,15 +188,6 @@ void wxRearrangeList::OnCheck(wxCommandEvent& event) m_order[n] = ~m_order[n]; } -int wxRearrangeList::DoInsertOneItem(const wxString& item, unsigned int pos) -{ - int ret = wxCheckListBox::DoInsertOneItem(item, pos); - // Item is not checked initially. - const int idx = ~m_order.size(); - m_order.Insert(idx, pos); - return ret; -} - int wxRearrangeList::DoInsertItems(const wxArrayStringsAdapter& items, unsigned int pos, void **clientData, wxClientDataType type) {