[patch] resize queuing




This patch fixes some things with queuing resizes.

* When a widget is destroyed, it needs to be removed from the list of
  pending resizes. (gtkwidget.c)
* In gtk_widget_show(), the widget should be the argument to 
  gtk_widget_queue_resize not the parent. (gtkwidget.c)
* When processing queued resizes, there may be some widgets
  without parents. These should be ignored.

These patches fix up a problem that was causing the GIMP's dbbrowser
to crash. (A sequence of gtk_widget_hide(), gtk_widget_destroy())
(Some of this stuff wasn't directly the culprit, but was found
while looking around).

On a similar note, shouldn't widgets be ref'd and unref'd while
a draw is pending so that they can't be destroyed in the
meantime?

Regards,
                                        Owen


diff -c -r -P -X patch-exclude gtk+970916.orig/gtk/gtkwidget.c gtk+970916/gtk/gtkwidget.c
*** gtk+970916.orig/gtk/gtkwidget.c	Mon Sep 15 18:12:58 1997
--- gtk+970916/gtk/gtkwidget.c	Wed Sep 24 16:15:09 1997
***************
*** 125,130 ****
--- 125,132 ----
  static void gtk_real_widget_size_allocate        (GtkWidget         *widget,
  						  GtkAllocation     *allocation);
  
+ static void gtk_widget_unqueue_resize        (GtkWidget *widget);
+ 
  static GdkColormap* gtk_widget_peek_colormap (void);
  static GdkVisual*   gtk_widget_peek_visual   (void);
  static GtkStyle*    gtk_widget_peek_style    (void);
***************
*** 803,808 ****
--- 805,811 ----
  void
  gtk_widget_destroy (GtkWidget *widget)
  {
+   gtk_widget_unqueue_resize (widget);
    if (widget->parent)
      {
        if (!GTK_OBJECT_BEING_DESTROYED (widget->parent))
***************
*** 1891,1903 ****
    if (height > -1)
      aux_info->height = height;
  
!   if (GTK_WIDGET_VISIBLE (widget))
!     {
!       if (widget->parent && GTK_WIDGET_VISIBLE (widget->parent))
! 	gtk_widget_queue_resize (GTK_WIDGET (widget->parent));
!       else if (GTK_IS_CONTAINER (widget))
! 	gtk_widget_queue_resize (widget);
!     }
  }
  
  /*****************************************
--- 1894,1901 ----
    if (height > -1)
      aux_info->height = height;
  
!   if (GTK_WIDGET_VISIBLE (widget) && widget->parent)
!     gtk_widget_queue_resize (widget);
  }
  
  /*****************************************
***************
*** 2833,2838 ****
--- 2831,2861 ----
      gdk_window_move_resize (widget->window,
  			    allocation->x, allocation->y,
  			    allocation->width, allocation->height);
+ }
+ 
+ /*****************************************
+  * gtk_widget_unqueue_resize:
+  *
+  *   arguments:
+  *
+  *   results:
+  *****************************************/
+ 
+ static void
+ gtk_widget_unqueue_resize (GtkWidget *widget)
+ {
+   GtkWidget *toplevel;
+   GSList *resize_widgets;
+ 
+   g_return_if_fail (widget != NULL);
+ 
+   toplevel = gtk_widget_get_toplevel (widget);
+   if (toplevel)
+     {
+       resize_widgets = gtk_object_get_data (GTK_OBJECT (toplevel), resize_widgets_key);
+       resize_widgets = g_slist_remove (resize_widgets, widget);
+       gtk_object_set_data (GTK_OBJECT (toplevel), resize_widgets_key, resize_widgets);
+     }
  }
  
  /*****************************************
diff -c -r -P -X patch-exclude gtk+970916.orig/gtk/gtkwindow.c gtk+970916/gtk/gtkwindow.c
*** gtk+970916.orig/gtk/gtkwindow.c	Mon Sep 15 01:29:30 1997
--- gtk+970916/gtk/gtkwindow.c	Wed Sep 24 16:11:01 1997
***************
*** 917,923 ****
                   (widget->allocation.height < widget->requisition.height)))
             widget = widget->parent;
  
!          GTK_WIDGET_SET_FLAGS (widget, GTK_RESIZE_PENDING);
         }
  
        resize_containers = NULL;
--- 917,924 ----
                   (widget->allocation.height < widget->requisition.height)))
             widget = widget->parent;
  
!          if (widget)
! 	   GTK_WIDGET_SET_FLAGS (widget, GTK_RESIZE_PENDING);
         }
  
        resize_containers = NULL;
***************
*** 933,951 ****
                  !GTK_WIDGET_RESIZE_PENDING (resize_container))
             resize_container = resize_container->parent;
  
!          widget = resize_container->parent;
!          while (widget)
!            {
!              if (GTK_WIDGET_RESIZE_PENDING (widget))
!                {
!                  GTK_WIDGET_UNSET_FLAGS (resize_container, GTK_RESIZE_PENDING);
!                  resize_container = widget;
!                }
!              widget = widget->parent;
!            }
! 
!          if (g_slist_find (resize_containers, resize_container) == NULL)
!            resize_containers = g_slist_prepend (resize_containers, resize_container);
         }
  
        g_slist_free (resize_widgets);
--- 934,955 ----
                  !GTK_WIDGET_RESIZE_PENDING (resize_container))
             resize_container = resize_container->parent;
  
! 	 if (resize_container)
! 	   {
! 	     widget = resize_container->parent;
! 	     while (widget)
! 	       {
! 		 if (GTK_WIDGET_RESIZE_PENDING (widget))
! 		   {
! 		     GTK_WIDGET_UNSET_FLAGS (resize_container, GTK_RESIZE_PENDING);
! 		     resize_container = widget;
! 		   }
! 		 widget = widget->parent;
! 	       }
! 	     
! 	     if (g_slist_find (resize_containers, resize_container) == NULL)
! 	       resize_containers = g_slist_prepend (resize_containers, resize_container);
! 	   }
         }
  
        g_slist_free (resize_widgets);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]