1
0
mirror of https://github.com/Kopano-dev/kopano-ol-extension.git synced 2023-10-10 13:37:40 +02:00

Added extra null checks to event registration, caused an exception when clicking around during full resync

This commit is contained in:
Patrick Simpson 2017-05-31 12:07:20 +02:00
parent 86b2144e22
commit b5ee982bc7

View File

@ -61,9 +61,9 @@ namespace Acacia.ZPush
protected override void DoRelease()
{
Cleanup();
_folder.Dispose();
_items.Dispose();
_subFolders.Dispose();
_folder?.Dispose();
_items?.Dispose();
_subFolders?.Dispose();
}
public override string ToString()
@ -113,26 +113,38 @@ namespace Acacia.ZPush
if (register)
{
// Item events
if (_items != null)
{
_items.ItemAdd += Items_ItemAdd;
_items.ItemChange += Items_ItemChange;
}
// Folder events
if (_subFolders != null)
{
_subFolders.FolderAdd += SubFolders_FolderAdd;
_subFolders.FolderRemove += SubFolders_FolderRemove;
_subFolders.FolderChange += SubFolders_FolderChange;
}
}
else
{
// Item events
if (_items != null)
{
_items.ItemAdd -= Items_ItemAdd;
_items.ItemChange -= Items_ItemChange;
}
// Folder events
if (_subFolders != null)
{
_subFolders.FolderAdd -= SubFolders_FolderAdd;
_subFolders.FolderRemove -= SubFolders_FolderRemove;
_subFolders.FolderChange -= SubFolders_FolderChange;
}
}
}
#region Event handlers