Skip to content

Commit

Permalink
fixed commandbar teardown - exception on exit has to do with referenc…
Browse files Browse the repository at this point in the history
…es events (sink?)
  • Loading branch information
retailcoder committed Oct 5, 2016
1 parent 5ffeacc commit 97a79ac
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
1 change: 0 additions & 1 deletion RetailCoder.VBE/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ private void ShutdownAddIn()
_kernel = null;
}

_addin.Release();
_ide.Release();
_isInitialized = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Rubberduck.UI.Command.MenuItems.ParentMenus
{
public abstract class ParentMenuItemBase : IParentMenuItem, IDisposable
public abstract class ParentMenuItemBase : IParentMenuItem
{
private readonly string _key;
private readonly int? _beforeIndex;
Expand Down Expand Up @@ -84,13 +84,11 @@ public void RemoveChildren()
var item = _items[child];
Debug.Assert(item is CommandBarPopup);
(item as CommandBarPopup).Delete();
item.Release();
}
foreach (var child in _items.Values.Select(item => item as CommandBarButton).Where(child => child != null))
{
child.Click -= child_Click;
child.Delete();
child.Release();
}
}

Expand Down Expand Up @@ -167,25 +165,5 @@ private void child_Click(object sender, CommandBarButtonClickEventArgs e)
Logger.Debug("({0}) Executing click handler for menu item '{1}', hash code {2}", GetHashCode(), e.Control.Caption, e.Control.GetHashCode());
item.Command.Execute(null);
}

~ParentMenuItemBase()
{
if (!_isDisposed)
{
Dispose();
}
}

private bool _isDisposed;
public void Dispose()
{
if (Item != null)
{
Item.Release();
}

_isDisposed = true;
GC.SuppressFinalize(this);
}
}
}
9 changes: 4 additions & 5 deletions RetailCoder.VBE/UI/Command/MenuItems/RubberduckCommandBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,10 @@ public void Dispose()
_sinks.ComponentActivated -= ComponentActivated;
_sinks.ComponentSelected -= ComponentSelected;

_refreshButton.Delete();
_selectionButton.Delete();
_statusButton.Delete();
_commandbar.Delete();
_commandbar.Release();
//_refreshButton.Delete();
//_selectionButton.Delete();
//_statusButton.Delete();
//_commandbar.Delete();
_isDisposed = true;
}
}
Expand Down
1 change: 0 additions & 1 deletion Rubberduck.VBEEditor/DisposableWrappers/VBA/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public override void Release()
{
if (!IsWrappingNullReference)
{
LinkedWindows.Release();
LinkedWindowFrame.Release();
Marshal.ReleaseComObject(ComObject);
}
Expand Down

0 comments on commit 97a79ac

Please sign in to comment.