gtk-timj-970919.patch




this is the readme of a patch i just uploaded to ftp.gimp.org:



gtk-timj-970919.patch		(against gtk+970916.tar.gz)

this patch corrects several things concerning the queued resizing and
redrawing.

- due to the reference counting caused by gtk_widget_queue_draw and
  gtk_widget_queue_resize, most widgets were not destroyed anymore.
  because a widget can be added to each of the queues just before
  it gets destroyed (e.g. through gtk_widget_hide or removing of
  a child) gtk_widget_destroy needs to remove the widgets from both
  of the queues.

- the GTK_RESIZE_NEEDED flag was only set once in `gtk_widget_queue_resize'
  and never unset.

- the handling of the resize queue in gtkwindow.c used GTK_RESIZE_PENDING to
  flag widgets internaly. also this was the location of a lot of segfaults
  due to NULL pointer access.

this patch has been extensively tested with the destroyment and recreation
of more then 10 windows (and subportions of their widget tree) at a time
and none of the widgets got lost in either one of the queues or failed to
get destroyed.
i'm not too sure wether we still need to reference a widget that has
GTK_RESIZE_NEEDED set because the reference is reset in gtk_widget_destroy,
but these parts are commented with `/* referencing needed? */'. anyways,
putting the referencing in showed some else problems, so i'm just leaving
it for the moment.



changes/additions:
	* gtk/gtkmain.h:
	* gtk/gtkmain.c: new function `gtk_idle_remove_by_data' to remove
	all idle callbacks that take a specific piece of data as argument.
	(gtk_get_current_event): remove idles through gtk_idle_remove_by_data.
	
	* gtk/gtkwidget.c:
	(gtk_widget_destroy): remove pending idles for
	widgets that have GTK_REDRAW_PENDING or GTK_RESIZE_PENDING and
	GTK_ANCHORED set (only anchored widgets can have a resize queue
	handler pending). widgets that have GTK_RESIZE_NEEDED will be removed
	from their anchored toplevels `resize_widgets' list.
	
	(gtk_widget_queue_draw): let the widget remember the queue handler
	tag (through `redraw_handler_key') for later call to `gtk_idle_remove'.
	
	(gtk_widget_queue_resize): let the widget remember the queue handler
	tag (through `resize_handler_key') for later call to `gtk_idle_remove'.
	corrected referencing the toplevel widget for which the handler is
	pending. if a widget is added to the `resize_widgets' list of a
	toplevel widget, GTK_RESIZE_NEEDED is set and it's referenced.
	
	(gtk_real_widget_queue_resize): on the deletion of the `resize_widgets'
	list, unset GTK_RESIZE_NEEDED and unreference the removed widgets.
	
	* gtk/gtkwindow.c:
	(gtk_real_window_move_resize): move `resize_containers = NULL'
	initialization out of if-statement.
	while stepping through the `resize_widgets' list, unreference the
	widgets and clear GTK_RESIZE_NEEDED. if a widget realy needs are
	resize, they are flagged through GTK_RESIZE_NEEDED now (instead of
	GTK_RESIZE_PENDING, as this is indicative for a pending handler).
	added checks to provide segfaulting if a widgets parent pointer
	is NULL (e.g. on toplevel widgets that have GTK_RESIZE_NEEDED set).


---
ciaoTJ



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