From 64ca527ecbcbbf715551b59a7248ef3b225894ce Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Tue, 3 Feb 1998 21:36:06 +0000 Subject: [PATCH] for the emission of AFTER signals, fetch the objects signals via Tue Feb 3 15:09:55 1998 Tim Janik * gtk/gtksignal.c (gtk_signal_real_emit): for the emission of AFTER signals, fetch the objects signals via gtk_signal_get_handlers again. some handlers might have been removed or added. not doing this would mess up the memchunk allocation of signal handlers (this had been triggered by multiple *_while_alive connections), bad, bad, bad! (gtk_handlers_run): do the referencing on signal handlers unconditionally, the invokation of AFTER handlers will now take care of modified lists. * gtk/gtksignal.h: added gtk_signal_connect_while_alive. --- ChangeLog | 14 ++++++++++++ ChangeLog.pre-2-0 | 14 ++++++++++++ ChangeLog.pre-2-10 | 14 ++++++++++++ ChangeLog.pre-2-2 | 14 ++++++++++++ ChangeLog.pre-2-4 | 14 ++++++++++++ ChangeLog.pre-2-6 | 14 ++++++++++++ ChangeLog.pre-2-8 | 14 ++++++++++++ gtk/gtkobject.c | 3 +++ gtk/gtksignal.c | 57 ++++++++++++++++++++++++++++++++++++++-------- gtk/gtksignal.h | 5 ++++ 10 files changed, 154 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index e08398b60f..b6661bda63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index e08398b60f..b6661bda63 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e08398b60f..b6661bda63 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e08398b60f..b6661bda63 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e08398b60f..b6661bda63 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e08398b60f..b6661bda63 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e08398b60f..b6661bda63 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +Tue Feb 3 15:09:55 1998 Tim Janik + + * gtk/gtksignal.c (gtk_signal_real_emit): for the emission + of AFTER signals, fetch the objects signals via + gtk_signal_get_handlers again. some handlers might have + been removed or added. not doing this would mess up the + memchunk allocation of signal handlers (this had been + triggered by multiple *_while_alive connections), bad, bad, bad! + (gtk_handlers_run): do the referencing on signal handlers + unconditionally, the invokation of AFTER handlers will now take + care of modified lists. + + * gtk/gtksignal.h: added gtk_signal_connect_while_alive. + Tue Feb 3 15:34:27 1998 Owen Taylor * gdk/gdkcolor.c (gdk_colormap_get_system): Only query diff --git a/gtk/gtkobject.c b/gtk/gtkobject.c index cb4e76999a..b5c0641a04 100644 --- a/gtk/gtkobject.c +++ b/gtk/gtkobject.c @@ -420,6 +420,9 @@ gtk_object_finalize (GtkObject *object) void gtk_object_sink (GtkObject *object) { + g_return_if_fail (object != NULL); + g_return_if_fail (GTK_IS_OBJECT (object)); + if (GTK_OBJECT_FLOATING (object)) { GTK_OBJECT_UNSET_FLAGS (object, GTK_FLOATING); diff --git a/gtk/gtksignal.c b/gtk/gtksignal.c index 55cca56917..cb4e7226e9 100644 --- a/gtk/gtksignal.c +++ b/gtk/gtksignal.c @@ -555,6 +555,37 @@ gtk_alive_disconnecter (GtkDisconnectInfo *info) return 0; } +void +gtk_signal_connect_while_alive (GtkObject *object, + const gchar *signal, + GtkSignalFunc func, + gpointer func_data, + GtkObject *alive_object) +{ + GtkDisconnectInfo *info; + + g_return_if_fail (object != NULL); + g_return_if_fail (GTK_IS_OBJECT (object)); + g_return_if_fail (signal != NULL); + g_return_if_fail (func != NULL); + g_return_if_fail (alive_object != NULL); + g_return_if_fail (GTK_IS_OBJECT (alive_object)); + + info = g_new (GtkDisconnectInfo, 1); + info->object1 = object; + info->object2 = alive_object; + + info->signal_handler = gtk_signal_connect (object, signal, func, func_data); + info->disconnect_handler1 = gtk_signal_connect_object (info->object1, + "destroy", + GTK_SIGNAL_FUNC (gtk_alive_disconnecter), + (GtkObject*) info); + info->disconnect_handler2 = gtk_signal_connect_object (info->object2, + "destroy", + GTK_SIGNAL_FUNC (gtk_alive_disconnecter), + (GtkObject*) info); +} + void gtk_signal_connect_object_while_alive (GtkObject *object, const gchar *signal, @@ -881,6 +912,13 @@ gtk_signal_handler_unref (GtkHandler *handler, { GtkHandler *tmp; + if (!handler->ref_count) + { + /* FIXME: i wanna get removed some when (maybe at gtk+-1.0?) */ + g_warning ("gtk_signal_handler_unref(): handler with ref_count==0!"); + return; + } + handler->ref_count -= 1; if (handler->ref_count == 0) { @@ -1013,6 +1051,7 @@ restart: NULL, params); } + handlers = gtk_signal_get_handlers (object, signal_type); switch (gtk_handlers_run (handlers, &info, TRUE)) { case DONE: @@ -1223,13 +1262,13 @@ gtk_handlers_run (GtkHandler *handlers, while (handlers) { - if (!after) - gtk_signal_handler_ref (handlers); + /* REMOVE: if (!after) */ + gtk_signal_handler_ref (handlers); if (handlers->signal_type != info->signal_type) { - if (after) - gtk_signal_handler_unref (handlers, info->object); + /* REMOVE: if (after) */ + gtk_signal_handler_unref (handlers, info->object); break; } @@ -1270,8 +1309,8 @@ gtk_handlers_run (GtkHandler *handlers, if (info->run_type & GTK_RUN_NO_RECURSE) gtk_emission_remove (&restart_emissions, info->object, info->signal_type); - if (after) - gtk_signal_handler_unref (handlers, info->object); + /* REMOVE: if (after) */ + gtk_signal_handler_unref (handlers, info->object); return DONE; } else if ((info->run_type & GTK_RUN_NO_RECURSE) && @@ -1280,14 +1319,14 @@ gtk_handlers_run (GtkHandler *handlers, { gtk_emission_remove (&restart_emissions, info->object, info->signal_type); - if (after) - gtk_signal_handler_unref (handlers, info->object); + /* REMOVE: if (after) */ + gtk_signal_handler_unref (handlers, info->object); return RESTART; } } handlers_next = handlers->next; - if (after) + /* if (after) */ gtk_signal_handler_unref (handlers, info->object); handlers = handlers_next; } diff --git a/gtk/gtksignal.h b/gtk/gtksignal.h index 108006de1f..39a793b192 100644 --- a/gtk/gtksignal.h +++ b/gtk/gtksignal.h @@ -113,6 +113,11 @@ void gtk_signal_connect_object_while_alive (GtkObject *object, const gchar *signal, GtkSignalFunc func, GtkObject *alive_object); +void gtk_signal_connect_while_alive (GtkObject *object, + const gchar *signal, + GtkSignalFunc func, + gpointer func_data, + GtkObject *alive_object); void gtk_signal_disconnect (GtkObject *object, gint anid);