After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 139410 - color_convert failed in GDK_VISUAL_PSEUDO_COLOR dia 0.92.2, 0.93
color_convert failed in GDK_VISUAL_PSEUDO_COLOR dia 0.92.2, 0.93
Status: RESOLVED OBSOLETE
Product: dia
Classification: Other
Component: general
0.93
Other Linux
: Low enhancement
: ---
Assigned To: Dia maintainers
Dia maintainers
Depends on:
Blocks:
 
 
Reported: 2004-04-07 19:20 UTC by Henry Nestler
Modified: 2019-03-20 11:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
color_convert gdk_colormap_alloc_color nonwritable for 8bit Dia 0.93 (1.32 KB, patch)
2005-04-05 18:44 UTC, Henry Nestler
none Details | Review

Description Henry Nestler 2004-04-07 19:20:02 UTC
Run dia Version 0.92.2 in environment with color depth 8 (256 colors) will 
only display up to 255 numbers of call color_convert. After 256-th call of 
these function, function failed. 
 
Simple open a new dia, than resize the diagram. Colours (Background and 
raster) fall into random colors and Error Message "color_convert failed" was 
displayed. 
 
Function use gdk_colormap_alloc_colors, but never free this. Should be call 
the gdk_colormap_free_colors? 
 
Using GIMP in same depth works good. 
If I change my color depth to 16 = GDK_VISUAL_TRUE_COLOR its works perfect. 
 
dia 0.92.2 
gtk 2.2.3 
XFree86 4.3.0.1 
Kernel 2.4.21 (Framebuffer and all other Xservers) 
GNU/GCC 3.3.1 
no gnome
Comment 1 Lars Clausen 2004-04-28 18:46:41 UTC
As far as I understand the gdk_colormap_alloc_colors code (see
http://mail.gnome.org/archives/gtk-devel-list/1998-August/msg00135.html, for
instance), gdk itself should handle this problem.
Comment 2 Hans Breuer 2005-02-16 21:28:30 UTC
From what I understand it will, if we use it correctly ;-)
But I don't have acces to such limited hardware or dont
know how to configure it so the following patch needs to 
be tested by someone else.

Thanks,
    Hans

diff --exclude-from=c:\util\tool\diff.ign -u --recursive
from-cvs/dia/lib/color.c my-gtk/dia/lib/color.c
--- from-cvs/dia/lib/color.c	Mon Aug 30 16:06:20 2004
+++ my-gtk/dia/lib/color.c	Fri Dec 03 12:40:19 2004
@@ -38,8 +38,12 @@
 color_init(void)
 {
   if (!_color_initialized) {
+#if 0
     GdkVisual *visual = gtk_widget_get_default_visual();
     colormap = gdk_colormap_new (visual, FALSE); 
+#else
+    colormap = gdk_rgb_get_cmap();
+#endif
 
     _color_initialized = TRUE;
 
Comment 3 Henry Nestler 2005-04-05 18:41:31 UTC
No, changing gdk_colormap_new not helps. Same problem.

I have change in function color_convert from
gdk_colormap_alloc_color (colormap, gdkcolor, TRUE, TRUE)
into
gdk_colormap_alloc_color (colormap, gdkcolor, FALSE, TRUE)

This woks better for that screen resolution. I change the attribut for color 
from writable into nonwritable. Change Dia the color map after alloc? I didn't 
see. Dia mostly alloc a color (named as function "color_convert"), draw 
something and forget this color after. And that is the problem. Dia "should" 
free the colour after using. Or should save the allocated color and use the 
same, allocated for next doing, if the same color is used (such draw the 
background).

Screen, before:
http://www.henrynestler.com/dia/Dia-ScreenShot38.png

Screen after gdk_colormap_alloc_color "writable = FALSE":
http://www.henrynestler.com/dia/Dia-ScreenShot35.png

Some of "g_warning" in function "color_init" are only for debuging. Interesting 
is, that the old unchanged gdk_colormap_alloc_color fails exactly after 256 
calls of the function color_convert().

With this I can use under 8 bit color, and found next problem:
Can't change color. Dia forget the color if I click to OK-Buttom in the Color 
selection Menu:
http://www.henrynestler.com/dia/Dia-ScreenShot38.png



Or sometimes Dia do not set the right color into background, on click to middle 
button "Change/Submit" (German "ubernehmen"):
http://www.henrynestler.com/dia/Dia-ScreenShot37.png
Comment 4 Henry Nestler 2005-04-05 18:44:55 UTC
Created attachment 39720 [details] [review]
color_convert gdk_colormap_alloc_color nonwritable for 8bit Dia 0.93

This works for first view.
Comment 5 Henry Nestler 2005-04-05 18:59:18 UTC
In addition of "alloc needs free" theory, I have change all caller functions of 
color_convert to free the color at end with a wrapper in color.c:

+void
+color_free_convert(GdkColor *gdkcolor)
+{
+    gdk_colormap_free_colors (colormap, gdkcolor, 1);
+}

This is interesting:

I can call more than thousend loops, before this function fails. Perhaps I have 
forgotton some calls of color_convert to free at end.

This function use the old writable attribut in this test!
color_convert()
...
   gdk_colormap_alloc_color (colormap, gdkcolor, TRUE, TRUE)

But it's perhaps generaly a design problem in Dia? Why a call to a function 
gdk_colormap_alloc_color nerver call a free function? Or why Dia don't cache 
the allocated color and give back the same pointer, if the same color?
Comment 6 Hans Breuer 2006-02-26 14:44:22 UTC
Reopening cause there is a bunch of information added. 
Personally I don't have any plans to work on this cause
none of my obsolete hardware is so restricted ;)
Comment 7 GNOME Infrastructure Team 2019-03-20 11:11:31 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/dia/issues/104.