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 606786 - smclient: add API for late registration with session manager
smclient: add API for late registration with session manager
Status: RESOLVED FIXED
Product: libegg
Classification: Other
Component: other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Libegg maintenance
Libegg maintenance
Depends on:
Blocks:
 
 
Reported: 2010-01-12 21:57 UTC by Vincent Untz
Modified: 2010-01-13 11:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Attaching patch again (2.35 KB, patch)
2010-01-12 21:58 UTC, Vincent Untz
needs-work Details | Review
Alternative approach (2.59 KB, patch)
2010-01-12 23:21 UTC, Vincent Untz
committed Details | Review

Description Vincent Untz 2010-01-12 21:57:48 UTC
The gnome-panel code connects to the session manager not immediately at startup, but after having set the struts (so nautilus only starts when this is set, and doesn't have to recompute the desktop).

EggSMClient doesn't make it easy, but with the attached patch, it's possible to set the mode to DISABLED at first, and then call a late egg_sm_client_startup().
Comment 1 Vincent Untz 2010-01-12 21:58:25 UTC
Created attachment 151292 [details] [review]
Attaching patch again
Comment 2 Dan Winship 2010-01-12 22:35:45 UTC
Comment on attachment 151292 [details] [review]
Attaching patch again

>+  if (global_client) {
>+    g_object_unref (global_client);
>+    global_client = NULL;
>+  }
>+
>+  egg_sm_client_set_mode (mode);
>+  client = egg_sm_client_get ();

That's kind of gross. It means that if you (or someone else, eg, the theoretical GtkApplication object) had previously called egg_sm_client_get(), then (a) if you kept a pointer to it, that pointer now points to a freed object, and (b) if you connected to the signals on it, then your signal handlers won't ever actually get called, because you'd connected to the signal handlers on the dummy client, not the real client.

It would be better to create the right EggSMClient right away, but tell it to delay registering. The code used to always delay registering until mainloop time, but that causes problems for apps that aren't autostarted, because they won't have an SM client id until after they finish registering, but you need to call gdk_set_sm_client_id() before creating any windows. So the code got changed. But it could be changed back to delaying registration if it already had a client ID (and the app asked it to).
Comment 3 Vincent Untz 2010-01-12 23:21:46 UTC
Created attachment 151295 [details] [review]
Alternative approach

(bah, the browser ate my comment)

You're right, of course. What about this approach?

We detect if a startup is needed in egg_sm_client_set_mode(). And we also make sure we cannot go back to DISABLED if it's too late with some g_return_if_fail() check.
Comment 4 Dan Winship 2010-01-13 00:36:11 UTC
Comment on attachment 151295 [details] [review]
Alternative approach

i didn't look too carefully, but yeah, that seems like it should work
Comment 5 Vincent Untz 2010-01-13 11:18:11 UTC
It definitely works with the panel :-) Thanks!