Trick list

Here is a list of trick, technic, tips, that I learned during my Summer of Code. It’s published here as it is, and my or may not interrest you.

Memory allocation with Glib:

memory allocation for objects:

– g_new (struct_type, number)
– g_renew (struct_type, old_allocation, number)
– g_unref_object (object)

simple allocation:

– g_malloc (byte_number)
– g_realloc (old_allocation, byte_number)
– g_free (allocation)
Allocation with g_malloc are expensive, use gslice instead if the memory needed is length fixed.

Hacking Gimp

gobject and glib debug

Run Gimp with –g-fatal-warnings

GTK event debug

When GTK send an event  (key press, mouse clic, ..), Gimp grabs the event manager. If you set a breackpoint in an event handler, this manager isn’t given back to GTK when the debugger freeze Gimp. Result, you cannot use your keyboard or mouse anymore. Not especially handy. Solution is to compile you own GTK with –enable-debug=yes, compile Gimp with this GTK, and run Gimp with –gtk-no-grabs.

Compilation options are available with ./configure –help

compilation without optimisation

CFLAGS=-O0 ./ –prefix=….

quick install of binaries only

cd app/ && sudo make install-binPROGRAMS


gobject is evil.

if you have a warning relative to glib or gobject, try make install

something wrong ? Try make install


Babl is a library used to abstract different pixel formal and color space (RVB, CMJN, …)

setup a format

babl_type (“float”)
babl_type (“u8”)
babl_format_n (babl_type (“float”), nombre_element)
Look in the doc to see format available. A small precision:
– R’: gamma adjusted
– Ra: pre-multiplied alpha

convert buffer with a Babl fish

babl_process (babl_fish, buffer_source, buffer_destination, nombre_d’element)


create a buffer

GeglBuffer *bfr = gegl_buffer_new (gegl_rectangle, babl_format)

buffer leak

In gegl/buffer/gegl_buffer.c, uncomment #define GEGL_BUFFER_DEBUG_ALLOCATION. When closing Gimp, you will have an allocation trace. You can convert adress in the binary in position in the source code with addr2line -e app/.libs/gimp-2.7 adress.


push in a remote branch

git push origin soc-2010-cage

keep branch up-to-date

git fetch origin && git rebase origin

Comments are closed.