[longomatch/newui: 87/157] Fix exception after disposing canvas objects
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/newui: 87/157] Fix exception after disposing canvas objects
- Date: Mon, 1 Sep 2014 09:48:40 +0000 (UTC)
commit 69d9632f532d8cde8a02da055a79f5429e021b45
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Aug 25 20:56:33 2014 +0200
Fix exception after disposing canvas objects
The singal handlers are not removed and triggered
after the object is disposed accessing to null Objects
LongoMatch.Drawing.Cairo/WidgetWrapper.cs | 21 +++++++++++++++++++++
LongoMatch.Drawing/Canvas.cs | 7 +++++++
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
index 5a9132c..6b0838f 100644
--- a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
+++ b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
@@ -55,6 +55,27 @@ namespace LongoMatch.Drawing.Cairo
widget.ButtonReleaseEvent += HandleButtonReleaseEvent;
widget.MotionNotifyEvent += HandleMotionNotifyEvent;
}
+
+ public void Dispose ()
+ {
+ Dispose (true);
+ System.GC.SuppressFinalize (this);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (disposing) {
+ if (moveTimerID != 0) {
+ GLib.Source.Remove (moveTimerID);
+ moveTimerID = 0;
+ }
+ if (hoverTimerID != 0) {
+ GLib.Source.Remove (hoverTimerID);
+
+ hoverTimerID = 0;
+ }
+ }
+ }
public uint MoveWaitMS {
get;
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index cc75c07..02f3773 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -138,6 +138,13 @@ namespace LongoMatch.Drawing
widget.ShowTooltipEvent += HandleShowTooltipEvent;
}
+ protected override void Dispose (bool disposing)
+ {
+ if (disposing)
+ widget.Dispose ();
+ base.Dispose (disposing);
+ }
+
public int ClickRepeatMS {
get;
set;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]