Skip to content

Commit d230df5

Browse files
authored
Merge pull request #3425 from mansellan/SaferComWrappers
VBComponents wrapper tweaks / null-checks.
2 parents 178f87d + 7a8f420 commit d230df5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Rubberduck.VBEEditor/SafeComWrappers/VBA/VBComponents.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public override int GetHashCode()
9999

100100
public void ImportSourceFile(string path)
101101
{
102+
if (IsWrappingNullReference) { return; }
103+
102104
var ext = Path.GetExtension(path);
103105
var name = Path.GetFileNameWithoutExtension(path);
104106
if (!File.Exists(path))
@@ -152,6 +154,8 @@ public void ImportSourceFile(string path)
152154

153155
public void RemoveSafely(IVBComponent component)
154156
{
157+
if (component.IsWrappingNullReference) { return; }
158+
155159
switch (component.Type)
156160
{
157161
case ComponentType.ClassModule:
@@ -174,7 +178,7 @@ private static void AttachEvents(VB.VBComponents components)
174178
{
175179
lock (Locker)
176180
{
177-
if (_components == null)
181+
if (_components == null && components != null)
178182
{
179183
_components = components;
180184
_componentAdded = OnComponentAdded;

0 commit comments

Comments
 (0)