[longomatch] Dispose background canvas surface correctly



commit 0201d7af032fb8bed07b7642748c5438071e8e9f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Jul 7 19:31:44 2014 +0200

    Dispose background canvas surface correctly

 LongoMatch.Drawing/Widgets/Blackboard.cs |   15 ++++++++++++++-
 LongoMatch.GUI/Gui/Dialog/DrawingTool.cs |    6 ++++++
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch.Drawing/Widgets/Blackboard.cs b/LongoMatch.Drawing/Widgets/Blackboard.cs
index ab329cf..ca0d267 100644
--- a/LongoMatch.Drawing/Widgets/Blackboard.cs
+++ b/LongoMatch.Drawing/Widgets/Blackboard.cs
@@ -28,7 +28,7 @@ using LongoMatch.Interfaces;
 
 namespace LongoMatch.Drawing.Widgets
 {
-       public class Blackboard: BackgroundCanvas
+       public class Blackboard: BackgroundCanvas, IDisposable
        {
        
                public event ShowDrawToolMenuHandler ShowMenuEvent;
@@ -50,6 +50,19 @@ namespace LongoMatch.Drawing.Widgets
                        tool = DrawTool.Selection;
                        
                }
+
+               public void Dispose(){
+                       Dispose(true);
+                       GC.SuppressFinalize(this);
+               }
+
+               protected virtual void Dispose(bool disposing){
+                       if (disposing) {
+                               if (backbuffer != null)
+                                       backbuffer.Dispose();
+                                       backbuffer = null;
+                       }
+               }       
                
                public FrameDrawing Drawing {
                        set {
diff --git a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
index 2db1f77..4ef67dd 100644
--- a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
+++ b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
@@ -88,6 +88,12 @@ namespace LongoMatch.Gui.Dialog
                        FillLineType ();
                }
                
+               public override void Destroy ()
+               {
+                       blackboard.Dispose();
+                       base.Destroy ();
+               }
+               
                void FillLineStyle () {
                        ListStore formatStore;
                        CellRendererPixbuf renderer = new CellRendererPixbuf();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]