-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean COM wrappers leak: Round 2 #4491
Clean COM wrappers leak: Round 2 #4491
Conversation
…te issues. Disable the analyzer due to numerous false positives.
Rubberduck.Core/UI/Command/MenuItems/CommandBars/AppCommandBarBase.cs
Outdated
Show resolved
Hide resolved
Rubberduck.Core/UI/Command/MenuItems/ParentMenus/ParentMenuItemBase.cs
Outdated
Show resolved
Hide resolved
Rubberduck.Core/UI/UnitTesting/Commands/AddTestModuleCommand.cs
Outdated
Show resolved
Hide resolved
Revert changes to RegistryAccess and IndenterSettings -- registry work requires more thought than simply wrapping a new using block.
Rubberduck.Core/UI/Command/MenuItems/CommandBars/AppCommandBarBase.cs
Outdated
Show resolved
Hide resolved
…nto CleanComSafeLeakRound2 # Conflicts: # Rubberduck.VBEditor.VBA/SafeComWrappers/Application/FallbackApp.cs # Rubberduck.VBEditor.VBA/SafeComWrappers/VB/VBE.cs # RubberduckTests/CodeExplorer/CodeExplorerTests.cs
@@ -235,6 +233,9 @@ public void Dispose() | |||
} | |||
|
|||
_disposed = true; | |||
_parser?.Dispose(); | |||
_vbe?.Dispose(); | |||
_tokenSource.Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are these after the flicking the _disposed
switch? That feels a little wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that was what we were supposed to -- if we throw during the dispose, the pooch is totally screwed anyway? At least subsequent calls would not throw again (but we're still screwed).
xmlSS.WriteEndElement(); //Close Worksheet | ||
xmlSS.WriteEndElement(); //Close Workbook | ||
xmlSS.WriteEndDocument(); | ||
xmlSS.Close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're touching this, one could try extract these blocks with an explanatory comment into their own methods...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I question whether we should be even doing that. Don't they provide some kind of API for writing OpenXMLs? Doing this all by hand feels wrong.... I'd rather defer that for another PR.
_typeInfosWrapped = _typeInfosWrapped ?? new DisposableList<TypeInfoWrapper>(); | ||
_typeInfosWrapped.Add(outVal); | ||
_typeInfosWrapped?.Dispose(); | ||
_typeInfosWrapped = _typeInfosWrapped ?? new DisposableList<TypeInfoWrapper>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and again
…nto CleanComSafeLeakRound2
…nto CleanComSafeLeakRound2 # Conflicts: # Rubberduck.CodeAnalysis/QuickFixes/IgnoreOnceQuickFix.cs # Rubberduck.Resources/Rubberduck.Resources.csproj
IDisposableAnalyzers
which helped few legitimate misuse ofIDisposable
. However I ended up commenting it out as we have far too many false positive. I left it as comment so once a PR addressing the issue Annotations for cases the analyzer can't figure out. DotNetAnalyzers/IDisposableAnalyzers#126 is merged, we can re-test using it.As noted in the comments for #3645, not all items in the COM safe get disposed due to
RaceOnRCWDisconnect
errors. This is attributed to the fact that there may be other threads running that accesses the SCWs during the shutdown. The PR does not address this as this should be its own PR. One possible fix for that is to implement theVBEEvents.TerminateEvents
to put in the necessary kill switch for command buttons and any other objects that needs to query a SCW.