diff options
author | iain holmes <iain@xamarin.com> | 2017-03-10 14:37:19 +0300 |
---|---|---|
committer | iain holmes <iain@xamarin.com> | 2017-03-10 14:37:19 +0300 |
commit | 7b1317b0b4ef680872f42dbe03ca19b18d917914 (patch) | |
tree | de14ab9e18b5d3403ca0b35775dd73df18a35de3 /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking | |
parent | 187292241c97b0cfcb3c6f8d52911152eeb75012 (diff) |
[A11y] Make ActionDelegate disposable
The arrays of actions are only generated whenever the actions change in order to avoid
constantly reallocating memory for them over and over, but this means the memory needs
to be freed when the ActionDelegate is no longer needed. Implement IDisposable and
call Dispose when the owner widget is destroyed
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockBarItem.cs | 13 | ||||
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs | 13 |
2 files changed, 24 insertions, 2 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockBarItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockBarItem.cs index 67d164147e..618a1e13d9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockBarItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockBarItem.cs @@ -133,9 +133,10 @@ namespace MonoDevelop.Components.Docking CrossfadeIcon crossfade; double hoverProgress; + ActionDelegate actionHandler; public DockBarItem (DockBar bar, DockItem it, int size) { - var actionHandler = new AtkCocoaHelper.ActionDelegate (); + actionHandler = new AtkCocoaHelper.ActionDelegate (); actionHandler.PerformPress += OnPerformPress; Accessible.SetActionDelegate (actionHandler); @@ -168,6 +169,16 @@ namespace MonoDevelop.Components.Docking Accessible.Name = "DockbarItem"; } + public override void Destroy () + { + if (actionHandler != null) { + actionHandler.Dispose (); + actionHandler = null; + } + + base.Destroy (); + } + void IAnimatable.BatchBegin () { } void IAnimatable.BatchCommit () { QueueDraw (); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs index 17c16f250d..116dd5f20b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs @@ -58,6 +58,7 @@ namespace MonoDevelop.Components.Docking DockItem item; bool allowPlaceholderDocking; bool mouseOver; + ActionDelegate actionHandler; IDisposable subscribedLeaveEvent; @@ -96,7 +97,7 @@ namespace MonoDevelop.Components.Docking public DockItemTitleTab (DockItem item, DockFrame frame) { - var actionHandler = new AtkCocoaHelper.ActionDelegate (); + actionHandler = new AtkCocoaHelper.ActionDelegate (); actionHandler.PerformPress += HandlePress; actionHandler.PerformShowMenu += HandleShowMenu; @@ -118,6 +119,16 @@ namespace MonoDevelop.Components.Docking subscribedLeaveEvent = this.SubscribeLeaveEvent (OnLeave); } + public override void Destroy () + { + if (actionHandler != null) { + actionHandler.Dispose (); + actionHandler = null; + } + + base.Destroy (); + } + public DockVisualStyle VisualStyle { get { return visualStyle; } set { |