Browse Source

Fix config selection

User wants to use that server after selected it in the ConfigForm. If user deletes
the server in use, we can't find its index, then the previous logic will revert to
index 0, which is not expected behaviour.

Since we handled 'ServersListBox.SelectedIndex' in various event handlers, we can
trust it all the time.

Signed-off-by: Syrone Wong <wong.syrone@gmail.com>
tags/3.3
Syrone Wong 8 years ago
parent
commit
514bb02098
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      shadowsocks-csharp/View/ConfigForm.cs

+ 4
- 2
shadowsocks-csharp/View/ConfigForm.cs View File

@@ -230,7 +230,6 @@ namespace Shadowsocks.View
private void OKButton_Click(object sender, EventArgs e)
{
Server server = controller.GetCurrentServer();
if (!SaveOldSelectedServer())
{
return;
@@ -241,7 +240,10 @@ namespace Shadowsocks.View
return;
}
controller.SaveServers(_modifiedConfiguration.configs, _modifiedConfiguration.localPort);
controller.SelectServerIndex(_modifiedConfiguration.configs.IndexOf(server));
// SelectedIndex remains valid
// We handled this in event handlers, e.g. Add/DeleteButton, SelectedIndexChanged
// and move operations
controller.SelectServerIndex(ServersListBox.SelectedIndex);
this.Close();
}


Loading…
Cancel
Save