From 12b857a329659ad04db0500869c6a1e56c7556ee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 22 Apr 2015 14:50:33 +0200 Subject: [PATCH] Fix infinite loop when deleting columns from wxTreeListCtrl. Wrong variable was checked in the loop adjusting the columns values resulting in an infinite loop. Closes #16955. --- docs/changes.txt | 1 + src/generic/treelist.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index b6b78063cf..6e9efe73f7 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -584,6 +584,7 @@ Unix: All (GUI): +- Fix hang when deleting columns from wxTreeListCtrl. - Fix several floating point rounding bugs in wxPropertyGrid (Artur Wieczorek). - Restore support for wxFD_OVERWRITE_PROMPT and wxFD_FILE_MUST_EXIST in wxGenericFileDialog which was accidentally lost some time ago (Carl Godkin). diff --git a/src/generic/treelist.cpp b/src/generic/treelist.cpp index 73fbe6c466..6c0e1e4d7c 100644 --- a/src/generic/treelist.cpp +++ b/src/generic/treelist.cpp @@ -170,10 +170,15 @@ public: wxScopedArray oldTexts(m_columnsTexts); m_columnsTexts = new wxString[numColumns - 2]; + + // As above, n is the index in the new column texts array and m is the + // index in the old one. for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ ) { - if ( n == col ) + if ( m == col ) { + // Skip copying the deleted column and keep the new index the + // same (so compensate for "n++" done in the loop). n--; } else // Not the deleted column.