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 634781 - StFocusManager needs to ref the groups added
StFocusManager needs to ref the groups added
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal critical
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks: 618312
 
 
Reported: 2010-11-13 22:11 UTC by Giovanni Campagna
Modified: 2010-11-14 20:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
StFocusManager: ref the added groups (964 bytes, patch)
2010-11-13 22:12 UTC, Giovanni Campagna
needs-work Details | Review
StFocusManager: don't unref removed groups (1.04 KB, patch)
2010-11-14 19:22 UTC, Giovanni Campagna
committed Details | Review

Description Giovanni Campagna 2010-11-13 22:11:12 UTC
The internal GHashTable has g_object_unref as the destroy notify, so of course we need to ref the objects we add.

This seems to fix the obnoxious bug from http://mail.gnome.org/archives/gnome-shell-list/2010-October/msg00070.html.
(At least, I hope so. Tracking it has be an huge pain, as it could be anywhere in gobject, gjs, clutter or gnome-shell itself, and I don't want to do it again).
Comment 1 Giovanni Campagna 2010-11-13 22:12:48 UTC
Created attachment 174408 [details] [review]
StFocusManager: ref the added groups

Take a ref when adding, so it can be dropped when removing.
Comment 2 Owen Taylor 2010-11-14 18:52:46 UTC
Review of attachment 174408 [details] [review]:

Good catch! The fix looks backwards to me ... the "destroy" signal on a ClutterActor is guaranteed to be run before it is freed (it's emitted from clutter_actor_dispose(), and any GObject is always reliably disposed at least once before finalization) so just using g_hash_table_new() without a DestroyNotify seems better to me. We don't want the focus manager to keep around an actor that would otherwise be freed.
Comment 3 Giovanni Campagna 2010-11-14 19:22:57 UTC
Created attachment 174455 [details] [review]
StFocusManager: don't unref removed groups

It is not referencing them when adding, and also it is connecting
to the "destroy" signal, emitted on dispose, so there is no risk
of storing finalized objects.
Comment 4 Owen Taylor 2010-11-14 19:34:14 UTC
Review of attachment 174455 [details] [review]:

+  manager->priv->groups = g_hash_table_new_full (NULL, NULL, NULL, NULL);

Is the same as 

+  manager->priv->groups = g_hash_table_new (NULL, NULL);

which is a little more readable. OK to commit with that change.