Skip to content

Commit 7e46746

Browse files
committed
Stop accessing components for no good reason in RubberduckParserState.ClearStateCache for project ids.
1 parent 58a1749 commit 7e46746

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Rubberduck.VBEditor.Application;
1818
using Rubberduck.VBEditor.ComManagement;
1919
using Rubberduck.VBEditor.Events;
20+
using Rubberduck.VBEditor.SafeComWrappers;
2021
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
2122

2223
// ReSharper disable LoopCanBeConvertedToQuery
@@ -697,20 +698,19 @@ public void ClearStateCache(string projectId)
697698
foreach (var moduleState in _moduleStates.Where(moduleState => moduleState.Key.ProjectId == projectId))
698699
{
699700
var qualifiedModuleName = moduleState.Key;
700-
var component = ProjectsProvider.Component(moduleState.Key);
701-
if (component != null)
701+
if (qualifiedModuleName.ComponentType == ComponentType.Undefined && qualifiedModuleName.ComponentType == ComponentType.ComComponent)
702702
{
703-
while (!ClearStateCache(qualifiedModuleName))
703+
if (_moduleStates.TryRemove(qualifiedModuleName, out var state))
704704
{
705-
// until Hell freezes over?
705+
state.Dispose();
706706
}
707707
}
708708
else
709709
{
710-
// store project module name
711-
if (_moduleStates.TryRemove(qualifiedModuleName, out var state))
710+
//This should be a user component.
711+
while (!ClearStateCache(qualifiedModuleName))
712712
{
713-
state.Dispose();
713+
// until Hell freezes over?
714714
}
715715
}
716716
}

0 commit comments

Comments
 (0)