This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[PATCH setup 1/3] Fix selecting sites added to the download site list box
- From: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- To: cygwin-apps at cygwin dot com
- Cc: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- Date: Mon, 21 Apr 2014 12:16:25 +0100
- Subject: [PATCH setup 1/3] Fix selecting sites added to the download site list box
- Authentication-results: sourceware.org; auth=none
- References: <1398078987-5116-1-git-send-email-jon dot turney at dronecode dot org dot uk>
Fix selecting sites added to the download site list box which have the same
protocol and hostname as an offical cygwin mirror.
If I add the site http://mirrors.kernel.org/sources.redhat.com/cygwinports/ to
setup's mirror list, using the GUI or --site option, I get two indistinguishable
entries named http://mirrors.kernel.org in the mirror list box.
Because PopulateListBox() uses the displayed string in the list control to
locate the itesm to select, we end up with a random one of those two
indistinguishable entries selected (usually the previously existing one).
Even if you manually correct the selection, the same problem will re-occur when
the selected sites are saved and restored on the next setup run.
Fix this by selecting by the index in the all_site_list vector, instead of by
displayed text.
2014-04-19 Jon TURNEY <jon.turney@dronecode.org.uk>
* site.cc (PopulateListBox): Select listbox items by finding the
index of the item with a matching full URL, not by LB_FINDSTRING
which does an inexact match on the displayed URL.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
---
site.cc | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/site.cc b/site.cc
index 2ed5d7b..e7d4113 100644
--- a/site.cc
+++ b/site.cc
@@ -637,10 +637,12 @@ SitePage::PopulateListBox ()
for (SiteList::const_iterator n = site_list.begin ();
n != site_list.end (); ++n)
{
- int index = SendMessage (listbox, LB_FINDSTRING, (WPARAM) - 1,
- (LPARAM) n->displayed_url.c_str());
- if (index != LB_ERR)
- {
+ SiteList::iterator i = find (all_site_list.begin(),
+ all_site_list.end(), *n);
+ if (i != all_site_list.end())
+ {
+ int index = i - all_site_list.begin();
+
// Highlight the selected item
SendMessage (listbox, LB_SELITEMRANGE, TRUE, (index << 16) | index);
// Make sure it's fully visible
--
1.8.5.5