Index: Core/Plugins/src/Core.Plugins.DotSpatial/Legend/MapLegendView.Designer.cs =================================================================== diff -u -r068e27ad7b5fb663d8f272d4aebbcf2d3e365abf -raadef283cdf782eaefc208b8a40df9c568fdaece --- Core/Plugins/src/Core.Plugins.DotSpatial/Legend/MapLegendView.Designer.cs (.../MapLegendView.Designer.cs) (revision 068e27ad7b5fb663d8f272d4aebbcf2d3e365abf) +++ Core/Plugins/src/Core.Plugins.DotSpatial/Legend/MapLegendView.Designer.cs (.../MapLegendView.Designer.cs) (revision aadef283cdf782eaefc208b8a40df9c568fdaece) @@ -7,19 +7,6 @@ /// private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - #region Component Designer generated code /// Index: Core/Plugins/src/Core.Plugins.DotSpatial/Legend/MapLegendView.cs =================================================================== diff -u -r068e27ad7b5fb663d8f272d4aebbcf2d3e365abf -raadef283cdf782eaefc208b8a40df9c568fdaece --- Core/Plugins/src/Core.Plugins.DotSpatial/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision 068e27ad7b5fb663d8f272d4aebbcf2d3e365abf) +++ Core/Plugins/src/Core.Plugins.DotSpatial/Legend/MapLegendView.cs (.../MapLegendView.cs) (revision aadef283cdf782eaefc208b8a40df9c568fdaece) @@ -100,6 +100,18 @@ } } + protected override void Dispose(bool disposing) + { + Data = null; + + if (disposing && (components != null)) + { + components.Dispose(); + } + + base.Dispose(disposing); + } + private void RegisterTreeNodeInfos() { treeViewControl.RegisterTreeNodeInfo(new TreeNodeInfo Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorer.cs =================================================================== diff -u -r961926e415b670350827c72e39751bfce40281ca -raadef283cdf782eaefc208b8a40df9c568fdaece --- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorer.cs (.../ProjectExplorer.cs) (revision 961926e415b670350827c72e39751bfce40281ca) +++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorer.cs (.../ProjectExplorer.cs) (revision aadef283cdf782eaefc208b8a40df9c568fdaece) @@ -104,17 +104,13 @@ protected override void Dispose(bool disposing) { + Data = null; + if (disposing && (components != null)) { components.Dispose(); } - if (treeViewControl != null) - { - Data = null; - treeViewControl.Dispose(); - } - base.Dispose(disposing); } Index: Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs =================================================================== diff -u -r068e27ad7b5fb663d8f272d4aebbcf2d3e365abf -raadef283cdf782eaefc208b8a40df9c568fdaece --- Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision 068e27ad7b5fb663d8f272d4aebbcf2d3e365abf) +++ Core/Plugins/test/Core.Plugins.DotSpatial.Test/Legend/MapLegendViewTest.cs (.../MapLegendViewTest.cs) (revision aadef283cdf782eaefc208b8a40df9c568fdaece) @@ -95,7 +95,6 @@ } } - [Test] public void Data_MapPointData_DataSet() { @@ -175,6 +174,22 @@ } } + [Test] + public void Dispose_Always_DataSetToNull() + { + // Setup + var mapLegendView = new MapLegendView(contextMenuBuilderProvider, parentWindow); + var treeViewControl = TypeUtils.GetField(mapLegendView, "treeViewControl"); + + // Call + mapLegendView.Dispose(); + + // Assert + Assert.IsNull(mapLegendView.Data); + Assert.IsNull(treeViewControl.Data); + Assert.IsTrue(treeViewControl.IsDisposed); + } + private MapFeature[] CreateFeature() { return new [] Index: Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs =================================================================== diff -u -r30b12b82918d500fe834eafd9f6cd9b2c5dbe60f -raadef283cdf782eaefc208b8a40df9c568fdaece --- Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs (.../LegendViewTest.cs) (revision 30b12b82918d500fe834eafd9f6cd9b2c5dbe60f) +++ Core/Plugins/test/Core.Plugins.OxyPlot.Test/Legend/LegendViewTest.cs (.../LegendViewTest.cs) (revision aadef283cdf782eaefc208b8a40df9c568fdaece) @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.Windows.Forms; +using Core.Common.Controls.TreeView; using Core.Common.Controls.Views; +using Core.Common.Utils.Reflection; using Core.Components.Charting.Data; using Core.Plugins.OxyPlot.Legend; using Core.Plugins.OxyPlot.Properties; @@ -69,5 +71,25 @@ Assert.Throws(test); } } + + [Test] + public void Dispose_Always_DataSetToNull() + { + // Setup + var legendView = new LegendView + { + Data = new ChartDataCollection(new List()) + }; + + var treeViewControl = TypeUtils.GetField(legendView, "treeViewControl"); + + // Call + legendView.Dispose(); + + // Assert + Assert.IsNull(legendView.Data); + Assert.IsNull(treeViewControl.Data); + Assert.IsTrue(treeViewControl.IsDisposed); + } } } \ No newline at end of file Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs =================================================================== diff -u -r961926e415b670350827c72e39751bfce40281ca -raadef283cdf782eaefc208b8a40df9c568fdaece --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision 961926e415b670350827c72e39751bfce40281ca) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision aadef283cdf782eaefc208b8a40df9c568fdaece) @@ -94,7 +94,7 @@ } [Test] - public void Dispose_Always_DisposeTreeViewControlResetDataAndDesubscribe() + public void Dispose_Always_DataSetToNull() { // Setup var mocks = new MockRepository(); @@ -121,8 +121,9 @@ explorer.Dispose(); // Assert - Assert.IsTrue(explorer.TreeViewControl.IsDisposed); Assert.IsNull(explorer.Data); + Assert.IsNull(explorer.TreeViewControl.Data); + Assert.IsTrue(explorer.TreeViewControl.IsDisposed); mocks.VerifyAll(); }