The application would not exit if closed with a connection dialog open. Performance improvement.

- Set owner form for some connection commands to ensure that the application
will exit if the user attempts to close the main window while a connection
dialog is visible.
- Do not iterate through all the VMs of the connection in order to close
potentially open VM dialogs.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2019-10-11 01:49:18 +01:00 committed by Mihaela Stoica
parent 11cd01900b
commit a18d6d3ccb
4 changed files with 23 additions and 30 deletions

View File

@ -66,7 +66,7 @@ namespace XenAdmin.Commands
{
c.CachePopulated += c_CachePopulated;
}
XenConnectionUI.BeginConnect(c, false, null, false);
XenConnectionUI.BeginConnect(c, false, Program.MainWindow, false);
});
}
}

View File

@ -69,7 +69,7 @@ namespace XenAdmin.Commands
{
item.Connection.CachePopulated += Connection_CachePopulated;
}
XenConnectionUI.BeginConnect(item.Connection, true, null, false);
XenConnectionUI.BeginConnect(item.Connection, true, Program.MainWindow, false);
}
}
}

View File

@ -199,7 +199,7 @@ namespace XenAdmin.Commands
if (socket.Connected)
{
MainWindowCommandInterface.Invoke(() => XenConnectionUI.BeginConnect(connection, false, null, false));
MainWindowCommandInterface.Invoke(() => XenConnectionUI.BeginConnect(connection, false, Program.MainWindow, false));
return;
}
i++;

View File

@ -2234,34 +2234,29 @@ namespace XenAdmin
{
Program.Invoke(Program.MainWindow, delegate
{
// Close and remove any active wizards for any VMs
foreach (VM vm in connection.Cache.VMs)
var vms = connection.Cache.VMs;
foreach (var kvp in activeXenModelObjectWizards)
{
CloseActiveWizards(vm);
}
closeActivePoolWizards(connection);
});
}
/// <summary>
/// Closes all per-Connection wizards.
/// </summary>
/// <param name="connection"></param>
private void closeActivePoolWizards(IXenConnection connection)
{
IList<Form> wizards;
if (activePoolWizards.TryGetValue(connection, out wizards))
{
foreach (var wizard in wizards)
{
if (!wizard.IsDisposed)
if (kvp.Key is VM vm && vms.Contains(vm))
{
wizard.Close();
if (kvp.Value is Form wizard && !wizard.IsDisposed)
wizard.Close();
activeXenModelObjectWizards.Remove(vm);
}
}
activePoolWizards.Remove(connection);
}
if (activePoolWizards.TryGetValue(connection, out IList<Form> wizards))
{
foreach (var wizard in wizards)
{
if (!wizard.IsDisposed)
wizard.Close();
}
activePoolWizards.Remove(connection);
}
});
}
/// <summary>
@ -2272,13 +2267,11 @@ namespace XenAdmin
{
Program.Invoke(Program.MainWindow, delegate
{
Form wizard;
if (activeXenModelObjectWizards.TryGetValue(obj, out wizard))
if (activeXenModelObjectWizards.TryGetValue(obj, out Form wizard))
{
if (!wizard.IsDisposed)
{
wizard.Close();
}
activeXenModelObjectWizards.Remove(obj);
}
});