Register events for connection only if a connection dialog does not exist already.

If they are registered on all cases and then unregistered and a new connection is
attempted, the connection dialog launched from the first connection attempt is
not closed after connection is established, because the connection events have
been unregistered.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2020-02-23 17:06:14 +00:00 committed by Mihaela Stoica
parent 7925bcae27
commit 711d1d0e63

View File

@ -58,19 +58,19 @@ namespace XenAdmin.Network
public static void BeginConnect(IXenConnection connection, bool interactive, Form owner, bool initiateMasterSearch)
{
Program.AssertOnEventThread();
RegisterEventHandlers(connection);
if (interactive)
{
// CA-214953 - Focus on this connection's dialog, if one exists, otherwise create one
if (connectionDialogs.TryGetValue(connection, out ConnectingToServerDialog dlg))
{
UnregisterEventHandlers(connection);
if (dlg.WindowState == FormWindowState.Minimized)
dlg.WindowState = FormWindowState.Normal;
dlg.Focus();
return;
}
RegisterEventHandlers(connection);
dlg = new ConnectingToServerDialog(connection);
connectionDialogs.Add(connection, dlg);
@ -78,7 +78,10 @@ namespace XenAdmin.Network
connectionDialogs.Remove(connection);
}
else
{
RegisterEventHandlers(connection);
((XenConnection)connection).BeginConnect(initiateMasterSearch, PromptForNewPassword);
}
}
private static bool PromptForNewPassword(IXenConnection connection, string oldPassword)