From 37f17672abce84144f514306d4f50e326d316e32 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sat, 5 Mar 2011 19:26:24 +0000 Subject: [PATCH] Fixed saving of sort orders Fascinating how apparently obvious bugs sometimes go unnoticed for a long time: - Switch between some sortings in the transfer window. - Close aMule. - Open aMule. Something different than last time is selected. - Close, open again. Now you have again what you had the first time. And 0 is a valid column. --- .svn-revision | 2 +- src/MuleListCtrl.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.svn-revision b/.svn-revision index f4b11002..6056c307 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10468 +10469 diff --git a/src/MuleListCtrl.cpp b/src/MuleListCtrl.cpp index 81bf7240..bc09d6cd 100644 --- a/src/MuleListCtrl.cpp +++ b/src/MuleListCtrl.cpp @@ -232,13 +232,21 @@ void CMuleListCtrl::LoadSettings() } else { // Sort orders wxStringTokenizer tokens(sortOrders, wxT(",")); + // Sort orders are stored in order primary, secondary, ... + // We want to apply them with SetSorting(), so we have to apply them in reverse order, + // so that the primary order is applied last and wins. + // Read them with tokenizer and store them in a list in reverse order. + CStringList tokenList; while (tokens.HasMoreTokens()) { - wxString token = tokens.GetNextToken(); + tokenList.push_front(tokens.GetNextToken()); + } + for (CStringList::iterator it = tokenList.begin(); it != tokenList.end(); it++) { + wxString token = *it; wxString name = token.BeforeFirst(wxT(':')); long order = StrToLong(token.AfterFirst(wxT(':')).BeforeLast(wxT(':'))); long alt = StrToLong(token.AfterLast(wxT(':'))); int col = GetColumnIndex(name); - if (col > 0) { + if (col >= 0) { SetSorting(col, (order ? SORT_DES : 0) | (alt ? SORT_ALT : 0)); } } -- 2.11.4.GIT