Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEberhard Beilharz <ermshiperete@users.noreply.github.com>2019-01-11 15:21:29 +0300
committerMarek Safar <marek.safar@gmail.com>2019-01-11 15:21:28 +0300
commit7952489bd2c6312165cfdf4df7741e92e36dc01c (patch)
tree7986df90ea0888877a528231f9d8fbb678973e9c /mcs/class/System.Windows.Forms
parent1e0bb426c74bc0b756828b10460c28576d375399 (diff)
[swf] Fix dispose of panels in StatusBar (#12355)
This change implements disposing of the panels of a status bar.
Diffstat (limited to 'mcs/class/System.Windows.Forms')
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs21
-rw-r--r--mcs/class/System.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs23
2 files changed, 37 insertions, 7 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs
index b6fd8bb6615..d7d4fc21848 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/StatusBar.cs
@@ -220,15 +220,22 @@ namespace System.Windows.Forms {
}
protected override void Dispose (bool disposing) {
- if (!IsDisposed)
+ if (!IsDisposed && disposing)
{
- if (disposing)
- {
- if (tooltip_timer != null)
- tooltip_timer.Dispose();
+ if (tooltip_timer != null)
+ tooltip_timer.Dispose();
- if (tooltip_window != null)
- tooltip_window.Dispose();
+ if (tooltip_window != null)
+ tooltip_window.Dispose();
+
+ if (panels != null) {
+ var copiedPanels = new StatusBarPanel [panels.Count];
+ ((ICollection) panels).CopyTo (copiedPanels, 0);
+ panels.Clear ();
+
+ foreach (StatusBarPanel panel in copiedPanels) {
+ panel.Dispose ();
+ }
}
}
diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
index cb27b91d6c1..b7fe976e81d 100644
--- a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
+++ b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/StatusBarTest.cs
@@ -86,6 +86,29 @@ namespace MonoTests.System.Windows.Forms
}
//[MonoTODO ("Test case for DrawItem")]
//[MonoTODO ("Test case for PanelClick")]
+
+ private class MyPanel: StatusBarPanel
+ {
+ public bool IsDisposed { get; private set; }
+
+ protected override void Dispose (bool disposing)
+ {
+ base.Dispose (disposing);
+ IsDisposed = true;
+ }
+ }
+
+ [Test]
+ public void DisposeTest ()
+ {
+ StatusBar sut = new StatusBar ();
+ MyPanel panel = new MyPanel ();
+ sut.Panels.Add (panel);
+
+ sut.Dispose ();
+
+ Assert.That (panel.IsDisposed, Is.True);
+ }
}
[TestFixture]