More questions on Colormaps and crashes...
- From: Colin Thomas <colin designresources co uk>
- To: gtk-app-devel-list gnome org
- Cc: colin designresources co uk
- Subject: More questions on Colormaps and crashes...
- Date: Fri, 29 Jun 2001 12:02:35 +0100 (BST)
Hi (again),
I have modified my code to apparently "free" allocated colorcells but I still
get crashes with:
Gdk-ERROR **: BadAlloc (insufficient resources for operation)
serial 38240 error_code 11 request_code 84 minor_code 0
In my application I need to refresh a Drawing area each second. The drawing
area is made up from a pixmap, which has hundreds of rectangles & polygons, whose
colours are limited to just 20, but continuously vary.
I create my 20 GdkColors, and each rect/poly is represented by a C++ class
which has a pointer, which points to the current colour (one of the 20).
When I am refreshing the pixmap for a particular rectangle I do the following:
/////////////////////////////////////////////////////////////
//Create a new color
GdkColor thisLayerColour[1];
//get the desired color from the particlaur rectangle class
thisLayerColour[0] = (*((*thisRect).GETColour()));
//Allocate the color
gdk_colormap_alloc_color (gdk_colormap_get_system () , &thisLayerColour[0] , FALSE, TRUE);
/Set the foreground colour
gdk_gc_set_foreground( thisGraphicsContext, &(thisLayerColour[0]) );
/////////////////////////////////////
//Create a rectangle to write to the pixmap
GdkRectangle update_rect;
update_rect.x = xl;
update_rect.y = yh;
update_rect.width = (xh - xl);
update_rect.height = (yl - yh);
/////////////////////////////////////
//draw rectangle to Pixmap
gdk_draw_rectangle (PixMap,
thisGraphicsContext,
TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height
);
//Free (?) the allocated colour
gdk_colormap_free_colors(gdk_colormap_get_system () ,thisLayerColour , 1);
/////////////////////////////////////////////////////////////
Everything works well (colours on the rectangles are changing), and then I get :
Gdk-ERROR **: BadAlloc (insufficient resources for operation)
serial 38240 error_code 11 request_code 84 minor_code 0
I would be grateful to know that the above code is actually freeing up the allocated colours, or have I
misconstrude something.
Can I get the number of current allocated colours from the colormap ?
I look forward to your collective thoughts....
best regards
/colin.
Date: Thu, 28 Jun 2001 17:51:10 +0100 (BST)
From: Colin Thomas <colin designresources co uk>
Subject: Dumb question re color allocation
To: gtk-app-devel-list gnome org
Cc: colin maggie
MIME-Version: 1.0
Content-MD5: jG8jx/2irAHFdQ2gk8qzgQ==
Hi,
This is probably a dumb question, but what the hell ;-)
The have a color defined i.e.
GdkColor guiColourPurple = {0, 0xffff, 0x0000, 0xffff};
I want to use this multiple times, in various windows.
Do I need to allocate just ONCE or for each usage ? (my gtk books
are a little vague on this)... i.e.
gdk_color_alloc (gdk_colormap_get_system () , &guiColourPurple);
If I know I have finished with a colour, can I/should I, de-allocate it ?
At present I am getting the following:
Gdk-ERROR **: BadAlloc (insufficient resources for operation)
serial 68077 error_code 11 request_code 84 minor_code 0
(I am on Solaris BTW)...
Many thanks in advance...
/colin.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Colin Thomas.
| Design Consultant.
|
| Email : colin designresources co uk
| Tele : (44) 1234 240562
| Fax : (44) 1234 241262
|
| Address : Design Resources,
| Old Cock Inn,
| Silver End,
| Olney,
| Buckinghamshire,
| United Kingdom.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]