Skip to content

Fix freeing objects

Samuel Thibault requested to merge sthibaul/java-atk-wrapper:GC into master

java-atk-wrapper actually never frees its jaw_impl objects. Indeed, there is never a g_object_unref() call for them. And then the corresponding java widget objects never get garbage-collected, since jaw_impl are keeping a global ref on them.

A way for java-atk-wrapper to know when it should free a jaw_impl object is to use global weak references: the GC will then feel free to collect the objects. java-atk-wrapper can then use IsSameObject(obj, NULL) to determine whether the object was collected, and then release the corresponding jaw_impl. This is what I have done here, going through the hash table of jaw_impl after GC has run.

Now, since we only have weak references on the widgets, we need to acquire a non-weak reference while working on them. This adds taking and releasing it in all cases.

We can keep global non-weak references for subparts of the widget (e.g. jawaction's jstrActionName etc.), they won't get collected until we release the jaw_impl of the widget, that is fine (and simpler).

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=793819

Merge request reports