2004-02-02 Mike Kestner <mkestner@ximian.com>

* glib/Value.cs : add dispose queue and idle handler so we can
	unset GValues that are created by the binding ctors.
	[Fixes #53490]

svn path=/trunk/gtk-sharp/; revision=22709
This commit is contained in:
Mike Kestner 2004-02-02 18:21:02 +00:00
parent 7fec283317
commit 84781a4d74
2 changed files with 44 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2004-02-02 Mike Kestner <mkestner@ximian.com>
* glib/Value.cs : add dispose queue and idle handler so we can
unset GValues that are created by the binding ctors.
[Fixes #53490]
2004-02-02 Todd berman <tberman@sevenl.net>
* gdk/Event*.custom: added fix for bug #53729.

View File

@ -7,6 +7,7 @@
namespace GLib {
using System;
using System.Collections;
using System.Runtime.InteropServices;
using GLibSharp;
@ -31,11 +32,39 @@ namespace GLib {
[DllImport("libglib-2.0-0.dll")]
static extern void g_free (IntPtr mem);
[DllImport("libgobject-2.0-0.dll")]
static extern void g_value_unset (IntPtr mem);
~Value ()
{
Dispose ();
}
static bool idle_queued;
static Queue idle_queue = new Queue ();
static bool DoDispose ()
{
IntPtr [] vals;
lock (idle_queue){
vals = new IntPtr [idle_queue.Count];
idle_queue.CopyTo (vals, 0);
idle_queue.Clear ();
}
lock (typeof (Value))
idle_queued = false;
foreach (IntPtr v in vals) {
if (v == IntPtr.Zero)
continue;
g_value_unset (v);
g_free (v);
}
return false;
}
public void Dispose () {
if (_val != IntPtr.Zero) {
IntPtr rawtype = gtksharp_value_get_value_type (_val);
@ -44,7 +73,15 @@ namespace GLib {
}
if (needs_dispose)
g_free (_val);
lock (idle_queue) {
idle_queue.Enqueue (_val);
lock (typeof (Value)){
if (!idle_queued){
Idle.Add (new IdleHandler (DoDispose));
idle_queued = true;
}
}
}
_val = IntPtr.Zero;
}
@ -54,7 +91,6 @@ namespace GLib {
}
}
// import the glue function to allocate values on heap
[DllImport("gtksharpglue")]