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

Re: [E-devel] Colormap issues in ecore_x_window_argb_internal_new()



On Sun, 10 Sep 2006 20:11:03 +0200 Tilman Sauerbeck <tilman@code-monkey.de>
babbled:

> Hi,
> when ecore_x creates an window with an ARGB visual, it creates a
> colormap for that visual (ecore_x_window.c:973).
> 
> This colormap is evaluated by XCreateWindow() etc.
> Afterwards, when the window has been set up, the colormap is freed (line
> 1010).
> 
> So now the colormap field in the XSetWindowAttributes structure of the
> window points to a freed chunk of memory.

aaah first. colormaps are id's not pointers. :) so they are server-side
resources. this is safe BECAUSE then the window has a REFERENCE to the colormap
thus it is keps alive and available due to reference count. this means we
don't leak colormaps as when the window is destroyed - the reference to the
colormap goes and thus the colormap is then freed :)

> Is this correct behaviour? When a window manager wants to take care of
> that window, it has to create the colormap again. There's no way it can
> find out whether the colormap pointer is valid, either - so it might
> waste resourrces by creating the color map.

nooo in this case the wm does nothing. the colormap is just for making
compositors and xrender happy. the wm doesn't do anything as the only thing a
wm would ever do is INSTALL the colormap (for 8bpp colormapps displays only) :)

> I'm probably wrong about a few of these points as my xlib knowledge is
> pretty limited :D
> But shouldn't we either omit the XFreeColormap() call or also reset the
> colormap field? The first alternative seems better to me.
> 
> GTK doesn't seem to free their colormaps, btw.

they probably free later on destroy of the window as they fully wrap the window
in a GdkWindow struct :)

> Thoughts?
> 
> Regards,
> Tilman
> 
> -- 
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    raster@rasterman.com
裸好多
Tokyo, Japan (東京 日本)