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 343705345b
commit 856c803887
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

@ -108,10 +108,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,14 +189,11 @@ 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 && _itemAdd != null)
{
if (item != null)
{
_itemAdd(item);
}
_itemAdd(item);
}
}
}
@ -239,14 +236,11 @@ 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 && _itemChange != null)
{
if (item != null)
{
_itemChange(item);
}
_itemChange(item);
}
}
}