[PATCH] gtkpixmap.c, bug in gtk_pixmap_set()



Hi,

this week someone reported a bug in the function gtk_pixmap_set ():
the old pixmap is not removed on screen when a new pixmap is
drawn. I suggested a call of gtk_widget_hide/gtk_widget_show to force a
redisplay. However, the following code snippet is more efficient:

GtkWidget *pw;
if (pw->window)
   gdk_window_clear_area (pw->window, pw->allocation.x, pw->allocation.y,
 		          pw->allocation.y, pw->allocation.width);
gtk_pixmap_set (pw, pixmap, mask);

Alternatively, gtkpixmap.c should be patched in this way:

Patch for gtk+-1.0.4:

*** gtkpixmap.c	Thu Jun 18 09:53:50 1998
--- gtkpixmap.c.new	Thu Jun 18 11:47:29 1998
***************
*** 133,138 ****
--- 133,144 ----
  	}
        if (GTK_WIDGET_VISIBLE (pixmap))
  	{
+ 	  if (GTK_WIDGET (pixmap)->window)
+ 	    gdk_window_clear_area (GTK_WIDGET (pixmap)->window,
+ 				   GTK_WIDGET (pixmap)->allocation.x,
+ 				   GTK_WIDGET (pixmap)->allocation.y,
+ 				   GTK_WIDGET (pixmap)->allocation.width,
+ 				   GTK_WIDGET (pixmap)->allocation.height); 
  	  if ((GTK_WIDGET (pixmap)->requisition.width != oldwidth) ||
  	      (GTK_WIDGET (pixmap)->requisition.height != oldheight))
  	    gtk_widget_queue_resize (GTK_WIDGET (pixmap));

Ullrich
-- 
Ullrich Hafner           <hafner@informatik.uni-wuerzburg.de>
Department of Computer Science, University Wuerzburg, Germany
URL:  http://www-info2.informatik.uni-wuerzburg.de/staff/ulli



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