Skip to content

Commit fc5ce70

Browse files
committed
Disallow reattaching COM events
1 parent abf9e6e commit fc5ce70

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Rubberduck.VBEEditor/SafeComWrappers/SafeRedirectedEventedComWrapper.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@ protected void AttachEvents(IEventSource<TEventSource> eventSource, TEventInterf
3535
if (eventSource == null || eventSink == null)
3636
{
3737
return;
38-
}
39-
40-
// Only one event source and one event sink supported at any given time
41-
DetachEvents();
38+
}
4239

4340
lock (_lock)
4441
{
4542
if (IsWrappingNullReference)
4643
{
4744
return;
4845
}
46+
47+
// Check that events not already attached
48+
if (_eventSource != null || _eventSink != null)
49+
{
50+
return;
51+
}
4952

5053
_eventSource = eventSource.EventSource;
5154
_eventSink = eventSink;

0 commit comments

Comments
 (0)