Skip to content

Commit f1c9125

Browse files
committed
Plug leaks in code explorer
1 parent 9c9fbc3 commit f1c9125

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Rubberduck.Core/Navigation/CodeExplorer/CodeExplorerComponentViewModel.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ public CodeExplorerComponentViewModel(CodeExplorerItemViewModel parent, Declarat
6868
var component = _projectsProvider.Component(qualifiedModuleName);
6969
string parenthesizedName;
7070
using (var properties = component.Properties)
71+
using (var nameProperty = properties["Name"])
7172
{
72-
parenthesizedName = properties["Name"].Value.ToString() ?? string.Empty;
73+
parenthesizedName = nameProperty.Value.ToString() ?? string.Empty;
7374
}
7475

7576
if (ContainsBuiltinDocumentPropertiesProperty())
@@ -113,7 +114,16 @@ private bool ContainsBuiltinDocumentPropertiesProperty()
113114
var component = _projectsProvider.Component(Declaration.QualifiedName.QualifiedModuleName);
114115
using (var properties = component.Properties)
115116
{
116-
return properties.Any(item => item.Name == "BuiltinDocumentProperties");
117+
foreach (var property in properties)
118+
using(property)
119+
{
120+
if (property.Name == "BuiltinDocumentProperties")
121+
{
122+
return true;
123+
}
124+
}
125+
126+
return false;
117127
}
118128
}
119129

0 commit comments

Comments
 (0)