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

[KOE-92] Turns out item Add and Change events pass a handle to a COM object that must be released. Changed the event handler to release it, with the global option ReleaseItemEventWrappers (default true) to revert back to old behaviour.

This commit is contained in:
Patrick Simpson 2017-04-12 11:53:09 +02:00
parent 9a37708b53
commit 8d79f9f2ee
3 changed files with 18 additions and 15 deletions

View File

@ -127,6 +127,16 @@ namespace Acacia
}
private static readonly BoolOption HOOK_ITEM_EVENTS = new BoolOption("HookItemEvents", true);
[AcaciaOption("Enables or disables the release of wrappers for item events. " +
"This should normally be enabled, but can be disabled to debug exceptions.")]
virtual public bool ReleaseItemEventWrappers
{
get { return GetOption(null, RELEASE_ITEM_EVENT_WRAPPERS); }
set { SetOption(null, RELEASE_ITEM_EVENT_WRAPPERS, value); }
}
private static readonly BoolOption RELEASE_ITEM_EVENT_WRAPPERS = new BoolOption("ReleaseItemEventWrappers", true);
#region UI Options
[AcaciaOption("Completely enables or disables modifications to the Outlook UI." +

View File

@ -113,10 +113,9 @@ namespace Acacia.Stubs.OutlookWrappers
{
get
{
using (ComRelease com = new ComRelease())
using (IBase parent = Mapping.Wrap<IBase>(_item.Parent))
{
NSOutlook.Folder parent = com.Add(_item.Parent);
return parent?.EntryID;
return parent.EntryID;
}
}
}

View File

@ -189,17 +189,14 @@ namespace Acacia.Stubs.OutlookWrappers
{
try
{
if (_itemAdd != null)
using (IItem item = Mapping.Wrap<IItem>(objItem, GlobalOptions.INSTANCE.ReleaseItemEventWrappers))
{
using (IItem item = Mapping.Wrap<IItem>(objItem, false))
{
if (item != null)
if (item != null && _itemAdd != null)
{
_itemAdd(item);
}
}
}
}
catch (System.Exception e)
{
Logger.Instance.Error(this, "Exception in HandleItemAdd: {0}", e);
@ -239,17 +236,14 @@ namespace Acacia.Stubs.OutlookWrappers
{
try
{
if (_itemChange != null)
using (IItem item = Mapping.Wrap<IItem>(objItem, GlobalOptions.INSTANCE.ReleaseItemEventWrappers))
{
using (IItem item = Mapping.Wrap<IItem>(objItem, false))
{
if (item != null)
if (item != null && _itemChange != null)
{
_itemChange(item);
}
}
}
}
catch (System.Exception e)
{
Logger.Instance.Error(this, "Exception in HandleItemChange: {0}", e);