Prevent from crashing if cancelling the Import wizard while on the Select host page.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2019-11-14 00:56:31 +00:00 committed by Mihaela Stoica
parent aca8be2939
commit 1050b14edc

View File

@ -51,7 +51,7 @@ namespace XenAdmin.Wizards.ImportWizard
{ {
private IEnumerable<Host> m_hostTargets; private IEnumerable<Host> m_hostTargets;
private bool m_buttonNextEnabled; private bool m_buttonNextEnabled;
private List<SR> m_srsWithRegisteredEvents = new List<SR>(); private readonly List<SR> m_srsWithRegisteredEvents = new List<SR>();
private readonly CollectionChangeEventHandler PBD_CollectionChangedWithInvoke; private readonly CollectionChangeEventHandler PBD_CollectionChangedWithInvoke;
public ImportOptionsPage() public ImportOptionsPage()
@ -136,10 +136,13 @@ namespace XenAdmin.Wizards.ImportWizard
private void DeregisterEvents() private void DeregisterEvents()
{ {
Connection.Cache.DeregisterCollectionChanged<PBD>(PBD_CollectionChangedWithInvoke); if (Connection != null)
{
Connection.Cache.DeregisterCollectionChanged<PBD>(PBD_CollectionChangedWithInvoke);
foreach (PBD pbd in Connection.Cache.PBDs) foreach (PBD pbd in Connection.Cache.PBDs)
pbd.PropertyChanged -= server_PropertyChanged; pbd.PropertyChanged -= server_PropertyChanged;
}
foreach (var sr in m_srsWithRegisteredEvents) foreach (var sr in m_srsWithRegisteredEvents)
sr.PropertyChanged -= server_PropertyChanged; sr.PropertyChanged -= server_PropertyChanged;