From f15bd558abe09627ea858dc7d88568b6df2fcb9e Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Mon, 11 May 1998 22:32:52 +0000 Subject: [PATCH] queue the idle_sizer with GTK_PRIORITY_INTERNAL - 1, so widgets get first Tue May 12 00:21:33 1998 Tim Janik * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then redrawn if that is still neccessary. don't allow queueing of already destructed objects. (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so widgets which are in the queue can be destroyed savely, handle requeueing properly. (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so widgets which are in the queue can be destroyed/unrealized savely. --- ChangeLog | 12 +++++++ ChangeLog.pre-2-0 | 12 +++++++ ChangeLog.pre-2-10 | 12 +++++++ ChangeLog.pre-2-2 | 12 +++++++ ChangeLog.pre-2-4 | 12 +++++++ ChangeLog.pre-2-6 | 12 +++++++ ChangeLog.pre-2-8 | 12 +++++++ gtk/gtkwidget.c | 90 +++++++++++++++++++++------------------------- 8 files changed, 125 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index c777ca0e9b..59517dee73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index c777ca0e9b..59517dee73 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c777ca0e9b..59517dee73 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index c777ca0e9b..59517dee73 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index c777ca0e9b..59517dee73 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c777ca0e9b..59517dee73 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c777ca0e9b..59517dee73 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Mon May 11 23:53:38 1998 Tim Janik + + * gtk/gtkwidget.c (gtk_widget_queue_resize): queue the idle_sizer with + GTK_PRIORITY_INTERNAL - 1, so widgets get first resized and then + redrawn if that is still neccessary. don't allow queueing of already + destructed objects. + (gtk_widget_idle_sizer): proccess the resize queue in a save manner, so + widgets which are in the queue can be destroyed savely, handle + requeueing properly. + (gtk_widget_idle_draw): proccess the redraw queue in a save manner, so + widgets which are in the queue can be destroyed/unrealized savely. + Mon May 11 17:54:44 BST 1998 Tony Gale * gtkfaq.sgml: add question on multi-threading, diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index d59b8f5e01..693ce57f64 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -187,7 +187,6 @@ static void gtk_widget_real_realize (GtkWidget *widget); static void gtk_widget_real_unrealize (GtkWidget *widget); static void gtk_widget_real_draw (GtkWidget *widget, GdkRectangle *area); -static gint gtk_widget_real_queue_draw (GtkWidget *widget); static void gtk_widget_real_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_widget_style_set (GtkWidget *widget, @@ -1555,23 +1554,10 @@ gtk_widget_unrealize (GtkWidget *widget) *****************************************/ static gint -gtk_widget_idle_draw (void *data) +gtk_widget_idle_draw (gpointer data) { - GSList *node; - GSList *draw_queue; - - draw_queue = node = gtk_widget_redraw_queue; - /* We set this gtk_widget_redraw_queue to NULL first, in case anybody - * calls queue_draw recursively - */ - gtk_widget_redraw_queue = NULL; - while (node) - { - gtk_widget_real_queue_draw ((GtkWidget*) node->data); - node = node->next; - } - - g_slist_free (draw_queue); + while (gtk_widget_redraw_queue) + gtk_widget_draw (gtk_widget_redraw_queue->data, NULL); return FALSE; } @@ -1600,7 +1586,8 @@ gtk_widget_queue_draw (GtkWidget *widget) GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_PENDING); if (gtk_widget_redraw_queue == NULL) gtk_idle_add_priority (GTK_PRIORITY_INTERNAL, - (GtkFunction) gtk_widget_idle_draw, NULL); + gtk_widget_idle_draw, + NULL); gtk_widget_redraw_queue = g_slist_prepend (gtk_widget_redraw_queue, widget); } @@ -1617,22 +1604,44 @@ gtk_widget_queue_draw (GtkWidget *widget) static gint gtk_widget_idle_sizer (void *data) { - GSList *slist, *free_slist; + GSList *slist; + GSList *re_queue; - free_slist = gtk_widget_resize_queue; - gtk_widget_resize_queue = NULL; - - for (slist = free_slist; slist; slist = slist->next) + re_queue = NULL; + while (gtk_widget_resize_queue) { GtkWidget *widget; - + + slist = gtk_widget_resize_queue; + gtk_widget_resize_queue = slist->next; widget = slist->data; - + GTK_PRIVATE_UNSET_FLAG (widget, GTK_RESIZE_PENDING); + + gtk_widget_ref (widget); if (gtk_container_need_resize (GTK_CONTAINER (widget))) - gtk_widget_queue_resize (widget); + { + slist->next = re_queue; + re_queue = slist; + } + else + { + g_slist_free_1 (slist); + gtk_widget_unref (widget); + } } - g_slist_free (free_slist); + + for (slist = re_queue; slist; slist = slist->next) + { + GtkWidget *widget; + + widget = slist->data; + if (GTK_OBJECT (widget)->ref_count > 1 && + !GTK_OBJECT_DESTROYED (widget)) + gtk_widget_queue_resize (widget); + gtk_widget_unref (widget); + } + g_slist_free (re_queue); return FALSE; } @@ -1643,6 +1652,8 @@ gtk_widget_queue_resize (GtkWidget *widget) GtkWidget *toplevel; g_return_if_fail (widget != NULL); + if (GTK_OBJECT_DESTROYED (widget)) + return; toplevel = gtk_widget_get_toplevel (widget); if (GTK_WIDGET_TOPLEVEL (toplevel)) @@ -1653,8 +1664,9 @@ gtk_widget_queue_resize (GtkWidget *widget) { GTK_PRIVATE_SET_FLAG (toplevel, GTK_RESIZE_PENDING); if (gtk_widget_resize_queue == NULL) - gtk_idle_add_priority (GTK_PRIORITY_INTERNAL, - (GtkFunction) gtk_widget_idle_sizer, NULL); + gtk_idle_add_priority (GTK_PRIORITY_INTERNAL - 1, + gtk_widget_idle_sizer, + NULL); gtk_widget_resize_queue = g_slist_prepend (gtk_widget_resize_queue, toplevel); } @@ -3745,26 +3757,6 @@ gtk_widget_real_draw (GtkWidget *widget, } } -/***************************************** - * gtk_widget_real_queue_draw: - * - * arguments: - * - * results: - *****************************************/ - -static gint -gtk_widget_real_queue_draw (GtkWidget *widget) -{ - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - - GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING); - gtk_widget_draw (widget, NULL); - - return FALSE; -} - /***************************************** * gtk_widget_real_size_allocate: *