If the user unchecks the box, remove all sites except for fresh
mirrors and selected stale mirrors.  Introduce a new function
remove_user_urls() to help with this
---
 site.cc | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/site.cc b/site.cc
index 0222ec9..9b7b816 100644
--- a/site.cc
+++ b/site.cc
@@ -259,6 +259,35 @@ check_for_user_urls ()
     }
 }
 
+static void
+remove_user_urls ()
+{
+  SiteList result;
+  for (SiteList::const_iterator i = all_site_list.begin ();
+       i != all_site_list.end (); i++)
+    {
+      if (i->from_mirrors_lst)
+       // It's a fresh mirror.
+       result.push_back (*i);
+      else
+       {
+         // Is it selected?
+         SiteList::iterator j = find (site_list.begin (),
+                                      site_list.end (), *i);
+         if (j != site_list.end ())
+           {
+             if (find (cached_site_list.begin (), cached_site_list.end (), *i)
+                 != cached_site_list.end ())
+               // It's a selected stale mirror.
+               result.push_back (*i);
+             else
+               site_list.erase (j);
+           }
+       }
+    }
+  all_site_list = result;
+}
+
 // This is called only for lists of mirrors that came (now or in a
 // previous setup run) from mirrors.lst.
 void
@@ -757,6 +786,12 @@ bool SitePage::OnMessageCmd (int id, HWND hwndctl, UINT 
code)
        if (code == BN_CLICKED)
          {
            allow_user_url = IsButtonChecked (IDC_ALLOW_USER_URL);
+           if (!allow_user_url)
+             {
+               // The button was just unchecked.
+               remove_user_urls ();
+               PopulateListBox ();
+             }
            CheckControlsAndDisableAccordingly ();
          }
        break;
-- 
2.15.1

Reply via email to