color "scribble-simple" eats up all memory & crashes
- From: Cevat Ustun <ustun Glue umd edu>
- To: gtk-app-devel-list gnome org
- Subject: color "scribble-simple" eats up all memory & crashes
- Date: Tue, 13 Feb 2001 16:35:07 -0500 (EST)
I have written a simple application that draws a series of points
given a starting point and gradually fills the screen (based on
scribble-simple.c from the gtk tutorials). The black &white version
works flawlessly but the color version quickly swells up all the
memory taken by X and ultimately crashes. Why?
Below is the generalized version of draw_brush from the tutorial
(I tried both -1 and 16 for my pixmap depths):
void draw_brush( GtkWidget *drawing_area,
gdouble x,
gdouble y,
glong red,
glong green,
glong blue)
{
GdkColor color;
GdkGC *custom_gc;
GdkRectangle update_rect;
/*create new gc*/
custom_gc=gdk_gc_new(drawing_area->window);
/*define the color by its components*/
color.red= red;
color.green=green;
color.blue= blue;
/*allocate color*/
if(!gdk_colormap_alloc_color(gdk_colormap_get_system(), &color,
FALSE,TRUE))
g_error("couldn't allocate color");
gdk_gc_set_foreground(custom_gc, &color);
update_rect.x = x ;
update_rect.y = y ;
update_rect.width = 1;
update_rect.height = 1;
gdk_draw_rectangle (pixmap,
custom_gc,
TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
gtk_widget_draw (drawing_area, &update_rect);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]