From 9f1a20a2be8b36023bdd10a638f7075d1f5e7970 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 6 Feb 2009 18:00:05 +0000 Subject: [PATCH] (svn r15377) -Fix [FS#2607]: filter did resort when unneeded and didn't deselect properly in some cases (Roujin) --- src/network/network_content_gui.cpp | 11 +++++++---- src/sortlist_type.h | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 5ae37eca1c..3c56a69c8b 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -279,15 +279,18 @@ class NetworkContentListWindow : public QueryStringBaseWindow, ContentCallback { { if (!this->content.Filter(this->edit_str_buf)) return; - this->selected = NULL; - this->list_pos = 0; - + /* update list position */ for (ConstContentIterator iter = this->content.Begin(); iter != this->content.End(); iter++) { if (*iter == this->selected) { this->list_pos = iter - this->content.Begin(); - break; + this->ScrollToSelected(); + return; } } + + /* previously selected item not in list anymore */ + this->selected = NULL; + this->list_pos = 0; } /** Make sure that the currently selected content info is within the visible part of the matrix */ diff --git a/src/sortlist_type.h b/src/sortlist_type.h index ba9f8a8d24..29c7cc4c3b 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -321,16 +321,18 @@ public: /* Do not filter if the filter bit is not set */ if (!HASBITS(this->flags, VL_FILTER)) return false; + bool changed = false; for (uint iter = 0; iter < this->items;) { T *item = &this->data[iter]; if (!decide(item, filter_data)) { this->Erase(item); + changed = true; } else { iter++; } } - return true; + return changed; } /**