Fixes in cl-gtk2-gobject memory managment

September 7, 2009

I’ve been debugging and fixing several bugs related to memory management of cl-gtk2.
There were two main bugs that required fixing:

  • Object denaturation. Object denaturation means that we pass a reference to an object of some type derived from GObject type but then we receive object of some other base type. E.g., we create a custom-window deriving from gtk-window with some fields containing application data. And if there are no references to custom-window and we receive a pointer to corresponding object, we receive it as a gtk-window, not custom-window.
    GObject’s toggle references are designed exactly to avoid this problem in language bindings. Toggle references let the binding know when the “foreign” side has no more references to an object (and this means that we will now never receive pointer to this object) and when the “foreign” side has some references (and may potentially pass object back to us).

  • References leak. There were cases when references were leaked: the cl-gtk2-gobject increased the objects’ refcount more than it should. Several generic cases of it have been fixed (references were increased twice when receiving the pointer from foreign code for the first time; functions that return already g_object_ref’ed objects).
  • Simplification of creation of GObject instances and instances of lisp-implemented GObject classes.

The changes are in git now.

But there is at least one case of reference leaking is present. Creating interface with GtkBuilder leaks some references.


One Response to “Fixes in cl-gtk2-gobject memory managment”

  1. Thura Says:

    Added on cliwiki,
    Cheers, this seems very promising 😉

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: