@@ -38,10 +38,7 @@ protected override void Initialize()
3838 _eventsHandlers = _dte . Events . DocumentEvents ;
3939 _eventsHandlers . DocumentSaved += documentSaved ;
4040
41- {
42- var outputWindow = ( OutputWindow ) _dte . GetOutputWindow ( ) . Object ;
43- _fileAnalysisOutputPane = outputWindow . OutputWindowPanes . Add ( "[cppcheck] File analysis output" ) ;
44- }
41+ _fileAnalysisOutputPane = _dte . AddOutputWindowPane ( "[cppcheck] File analysis output" ) ;
4542
4643 _analyzers . Add ( new AnalyzerCppcheck ( ) ) ;
4744
@@ -63,20 +60,31 @@ protected override void Initialize()
6360 }
6461 }
6562
63+ protected override void Dispose ( bool disposing )
64+ {
65+ cleanup ( ) ;
66+ base . Dispose ( disposing ) ;
67+ }
68+
6669 protected override int QueryClose ( out bool canClose )
6770 {
6871 int result = base . QueryClose ( out canClose ) ;
6972 if ( canClose )
7073 {
71- foreach ( var item in _analyzers )
72- {
73- item . Dispose ( ) ;
74- }
74+ cleanup ( ) ;
7575 }
7676 return result ;
7777 }
7878 #endregion
7979
80+ private void cleanup ( )
81+ {
82+ foreach ( var item in _analyzers )
83+ {
84+ item . Dispose ( ) ;
85+ }
86+ }
87+
8088 private void onCheckCurrentProjectRequested ( object sender , EventArgs e )
8189 {
8290 checkCurrentProject ( ) ;
@@ -138,7 +146,8 @@ private void checkCurrentProject()
138146 return ;
139147 }
140148 currentConfig = ( ( Project ) o ) . ConfigurationManager . ActiveConfiguration ;
141- foreach ( dynamic file in project . Files )
149+ dynamic projectFiles = project . Files ;
150+ foreach ( dynamic file in projectFiles )
142151 {
143152 Type fileObjectType = file . GetType ( ) ;
144153 // Automatic property binding fails with VS2013 for some unknown reason, using Reflection directly instead.
@@ -164,8 +173,7 @@ private void checkCurrentProject()
164173
165174 if ( _projectAnalysisOutputPane == null )
166175 {
167- var outputWindow = ( OutputWindow ) _dte . GetOutputWindow ( ) . Object ;
168- _projectAnalysisOutputPane = outputWindow . OutputWindowPanes . Add ( "[cppcheck] Project analysis output" ) ;
176+ _projectAnalysisOutputPane = _dte . AddOutputWindowPane ( "[cppcheck] Project analysis output" ) ;
169177 }
170178
171179 runAnalysis ( files , currentConfig , true , _projectAnalysisOutputPane ) ;
@@ -181,6 +189,7 @@ private void runAnalysis(SourceFile file, Configuration currentConfig, bool brin
181189 private void runAnalysis ( List < SourceFile > files , Configuration currentConfig , bool bringOutputToFrontAfterAnalysis , OutputWindowPane outputPane )
182190 {
183191 Debug . Assert ( outputPane != null ) ;
192+ Debug . Assert ( currentConfig != null ) ;
184193 outputPane . Clear ( ) ;
185194 var currentConfigName = currentConfig . ConfigurationName ;
186195 foreach ( var analyzer in _analyzers )
0 commit comments