2008-05-28 Mike Kestner <mkestner@novell.com>

* gtk/Object.custom: move Dispose call to a vm override so that
	it runs after all signals and native overrides have run.
	* gtk/glue/object.c: destroy override implementation.

svn path=/trunk/gtk-sharp/; revision=104315
This commit is contained in:
Mike Kestner 2008-05-28 18:59:53 +00:00
parent d6be561887
commit f3f0a62918
3 changed files with 52 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2008-05-28 Mike Kestner <mkestner@novell.com>
* gtk/Object.custom: move Dispose call to a vm override so that
it runs after all signals and native overrides have run.
* gtk/glue/object.c: destroy override implementation.
2008-05-28 Lluis Sanchez Gual <lluis@novell.com>
* gtk/Object.custom: If all destroy handlers have been

View File

@ -21,6 +21,30 @@
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
[DllImport("gtksharpglue-2")]
private static extern bool gtksharp_object_override_destroy (DestroyVMDelegate handler);
static DestroyVMDelegate destroy_vm_handler;
static Object ()
{
destroy_vm_handler = new DestroyVMDelegate (DestroyVMCallback);
gtksharp_object_override_destroy (destroy_vm_handler);
}
[GLib.CDeclCallback]
delegate void DestroyVMDelegate (IntPtr handle);
static void DestroyVMCallback (IntPtr handle)
{
try {
GLib.Object obj = GLib.Object.GetObject (handle, false);
if (obj != null)
obj.Dispose ();
} catch (Exception) {
}
}
static Hashtable destroy_handlers;
static Hashtable DestroyHandlers {
get {
@ -46,7 +70,6 @@
handler (this, EventArgs.Empty);
DestroyHandlers.Remove (Handle);
}
Dispose ();
}
[GLib.Signal("destroy")]

View File

@ -26,6 +26,7 @@
void gtksharp_object_unref_if_floating (GObject *obj);
gboolean gtksharp_object_is_floating (GObject *obj);
void gtksharp_object_set_floating (GtkObject *obj, gboolean val);
void gtksharp_object_override_destroy (gpointer cb);
/* */
void
@ -50,3 +51,24 @@ gtksharp_object_set_floating (GtkObject *obj, gboolean val)
gtk_object_sink (obj);
}
typedef void (* destroy_func) (GtkObject *obj);
static destroy_func base_destroy;
static destroy_func managed_destroy;
static void
my_destroy (GtkObject *obj)
{
(* managed_destroy) (obj);
(* base_destroy) (obj);
}
void
gtksharp_object_override_destroy (gpointer cb)
{
GtkObjectClass *klass = (GtkObjectClass *) g_type_class_ref (GTK_TYPE_OBJECT);
base_destroy = klass->destroy;
managed_destroy = cb;
klass->destroy = my_destroy;
}