Skip to content

Commit 6e2a98a

Browse files
committed
Expand the lock's scopes.
1 parent 91201a8 commit 6e2a98a

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

Rubberduck.VBEEditor/Events/VbeEvents.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public sealed class VBEEvents : IVBEEvents
1515

1616
public static VBEEvents Initialize(IVBE vbe)
1717
{
18-
if (_instance == null)
18+
lock (Lock)
1919
{
20-
lock (Lock)
20+
if (_instance == null)
2121
{
2222
_instance = new VBEEvents(vbe);
2323
}
@@ -28,13 +28,13 @@ public static VBEEvents Initialize(IVBE vbe)
2828

2929
public static void Terminate()
3030
{
31-
if (_instance == null)
32-
{
33-
return;
34-
}
35-
3631
lock (Lock)
3732
{
33+
if (_instance == null)
34+
{
35+
return;
36+
}
37+
3838
_instance.Dispose();
3939
_instance = null;
4040
}

Rubberduck.VBEEditor/Rubberduck.VBEditor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
<Compile Include="Events\ProjectEventArgs.cs" />
148148
<Compile Include="Events\ProjectRenamedEventArgs.cs" />
149149
<Compile Include="Events\SelectionChangedEventArgs.cs" />
150-
<Compile Include="Events\VbeEvents.cs" />
150+
<Compile Include="Events\VBEEvents.cs" />
151151
<Compile Include="Events\VBENativeServices.cs" />
152152
<Compile Include="Events\WindowChangedEventArgs.cs" />
153153
<Compile Include="Extensions\VBComponentExtensions.cs" />

Rubberduck.VBEEditor/SafeComWrappers/SafeEventedComWrapper.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ protected override void Dispose(bool disposing)
2525

2626
public void AttachEvents()
2727
{
28-
if (IsWrappingNullReference)
28+
lock (_lock)
2929
{
30-
return;
31-
}
30+
if (IsWrappingNullReference)
31+
{
32+
return;
33+
}
3234

33-
if (_cookie != NotAdvising)
34-
{
35-
return;
36-
}
35+
if (_cookie != NotAdvising)
36+
{
37+
return;
38+
}
3739

38-
lock (_lock)
39-
{
4040
// Call QueryInterface for IConnectionPointContainer
4141
var icpc = (IConnectionPointContainer) Target;
4242

0 commit comments

Comments
 (0)