[evolution-patches] patch to fix colormap initialisation in gtkhtml's gdk painter



I'm working on a product which uses Balsa on a small ARM-based handheld device with the kdrive X server (in 16bpp). When rendering any HTML e-mail, balsa issued the following warning:

(balsa:11338): Gdk-WARNING **: Using Xft rendering requires the drawable
argument to have a specified colormap. All windows have a colormap,
however, pixmaps only have colormap by default if they
were created with a non-NULL window argument. Otherwise
a colormap must be set on them with gdk_drawable_set_colormap

And then crashed with backtraces along these lines:

#0  0x416754d3 in XftDrawSetClip () from /usr/lib/libXft.so.2
#1  0x40f3cab4 in _gdk_x11_have_render () from /usr/lib/libgdk-x11-2.0.so.0
#2  0x40f3d7be in _gdk_x11_have_render () from /usr/lib/libgdk-x11-2.0.so.0
#3  0x40f1800c in gdk_draw_glyphs () from /usr/lib/libgdk-x11-2.0.so.0
#4  0x40f21d15 in gdk_pixmap_get_type () from /usr/lib/libgdk-x11-2.0.so.0
#5  0x40f1800c in gdk_draw_glyphs () from /usr/lib/libgdk-x11-2.0.so.0
#6 0x40084c98 in html_gdk_painter_text_itemize_and_prepare_glyphs () from /usr/lib/libgtkhtml-3.0.so.4

This crash was also reproducable when running balsa on an i386, only displaying on the handheld. Debugging in this situation revealed that this crash is actually within the draw_text function in htmlgtkpainter.c, and that after begin() is called, the colormap of gdk_painter->pixmap was null.

The attached patch fixes the crash here by providing gdk_painter->window when initialising the pixmap, which lets Gdk find the right colormap for the drawable, and avoids the need to get the viewable to find the colour depth. Although against gtkhtml 3.0.10 the code looks the same in CVS so should apply fine.

The only thing I havn't yet figured out is why it crashes on this handheld's kdrive X server but not on any of our desktop machines XFree86 X servers. Maybe because they are all 32bpp? Answers on a postcard.

Regards,
Rob
--- gtkhtml-3.0.10/src/htmlgdkpainter.c.orig	2004-07-23 17:07:05.000000000 +0100
+++ gtkhtml-3.0.10/src/htmlgdkpainter.c	2004-07-23 17:17:09.000000000 +0100
@@ -277,22 +277,19 @@
 begin (HTMLPainter *painter, int x1, int y1, int x2, int y2)
 {
 	HTMLGdkPainter *gdk_painter;
-	GdkVisual *visual;
 
 	/* printf ("painter begin %d,%d %d,%d\n", x1, y1, x2, y2); */
 
 	gdk_painter = HTML_GDK_PAINTER (painter);
 	g_return_if_fail (gdk_painter->window != NULL);
-	visual = gdk_drawable_get_visual (gdk_painter->window);
-	g_return_if_fail (visual != NULL);
 
 	if (gdk_painter->double_buffer){
 		const int width = x2 - x1 + 1;
 		const int height = y2 - y1 + 1;
 
 		g_assert (gdk_painter->pixmap == NULL);
-		
-		gdk_painter->pixmap = gdk_pixmap_new (gdk_painter->pixmap, width, height, visual->depth);
+
+		gdk_painter->pixmap = gdk_pixmap_new (gdk_painter->window, width, height, -1);
 		gdk_painter->x1 = x1;
 		gdk_painter->y1 = y1;
 		gdk_painter->x2 = x2;
@@ -313,6 +310,8 @@
 		gdk_painter->x2 = 0;
 		gdk_painter->y2 = 0;
 	}
+
+	g_assert(gdk_drawable_get_colormap(gdk_painter->pixmap) != NULL);
 }
 
 static void


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