Skip to content

Commit 2d5e661

Browse files
committed
Cleanup and logic correction
1 parent 5732aa1 commit 2d5e661

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Rubberduck.Core/UI/Command/MenuItems/ParentMenus/CommandBarButtonFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ public class CommandBarButtonFactory : ICommandBarButtonFactory
1818
private readonly IVBEEvents _vbeEvents;
1919
private readonly List<CommandBarButton> _buttons;
2020

21-
internal CommandBarButtonFactory(IVBEEvents vbeEvents)
21+
public CommandBarButtonFactory(IVBEEvents vbeEvents)
2222
{
23+
_buttons = new List<CommandBarButton>();
2324
_vbeEvents = vbeEvents;
2425
_vbeEvents.EventsTerminated += EventsTerminated;
2526
}

Rubberduck.VBEEditor/SafeComWrappers/Office.Core/CommandBarButton.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Rubberduck.VBEditor.SafeComWrappers.Office.Core
1515
{
16-
public class CommandBarButton : SafeEventedComWrapper<MSO.CommandBarButton, MSO.ICommandBarsEvents>, ICommandBarButton, MSO.ICommandBarButtonEvents
16+
public class CommandBarButton : SafeEventedComWrapper<MSO.CommandBarButton, MSO._CommandBarButtonEvents>, ICommandBarButton, MSO._CommandBarButtonEvents
1717
{
1818
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
1919
public const bool AddCommandBarControlsTemporarily = false;
@@ -371,19 +371,19 @@ public override bool Equals(ISafeComWrapper<MSO.CommandBarButton> other)
371371
&& ReferenceEquals(other.Target.Parent, Target.Parent));
372372
}
373373

374-
private object _eventLock = new object();
374+
private readonly object _eventLock = new object();
375375
private event EventHandler<CommandBarButtonClickEventArgs> _click;
376376
public event EventHandler<CommandBarButtonClickEventArgs> Click
377377
{
378378
add
379379
{
380380
lock (_eventLock)
381381
{
382-
if (_click != null && _click.GetInvocationList().Length == 0)
382+
_click += value;
383+
if (_click != null && _click.GetInvocationList().Length != 0)
383384
{
384385
AttachEvents();
385386
}
386-
_click += value;
387387
}
388388
}
389389
remove
@@ -399,7 +399,7 @@ public event EventHandler<CommandBarButtonClickEventArgs> Click
399399
}
400400
}
401401

402-
void MSO.ICommandBarButtonEvents.Click(MSO.CommandBarButton Ctrl, ref bool CancelDefault)
402+
void MSO._CommandBarButtonEvents.Click(MSO.CommandBarButton Ctrl, ref bool CancelDefault)
403403
{
404404
var button = new CommandBarButton(Ctrl);
405405
var handler = _click;

0 commit comments

Comments
 (0)