summaryrefslogtreecommitdiffstats
path: root/src/ck-seat.c
diff options
context:
space:
mode:
authorWilliam Jon McCann <mccann@jhu.edu>2007-10-10 12:53:45 -0400
committerWilliam Jon McCann <mccann@jhu.edu>2007-10-10 12:53:45 -0400
commitbd43c78b3ab2ec7f85b17cca46d4b46f8671cd29 (patch)
tree0560ef7122b69f9f64f1eff054d620ab1398ad6e /src/ck-seat.c
parenta90ecd3544f03c16f6c5a97aafb1c0b33b58101c (diff)
remove session/seat from list before signaling
We should remove the session or seat from the lists before calling out or emitting a signal. We steal from the lists and then unref the objects when the signal is complete.
Diffstat (limited to 'src/ck-seat.c')
-rw-r--r--src/ck-seat.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/ck-seat.c b/src/ck-seat.c
index 63d7b6c..66bf728 100644
--- a/src/ck-seat.c
+++ b/src/ck-seat.c
@@ -528,8 +528,11 @@ ck_seat_remove_session (CkSeat *seat,
CkSession *session,
GError **error)
{
- char *ssid;
- gboolean ret;
+ char *ssid;
+ char *orig_ssid;
+ CkSession *orig_session;
+ gboolean res;
+ gboolean ret;
g_return_val_if_fail (CK_IS_SEAT (seat), FALSE);
@@ -537,7 +540,12 @@ ck_seat_remove_session (CkSeat *seat,
ssid = NULL;
ck_session_get_id (session, &ssid, NULL);
- if (g_hash_table_lookup (seat->priv->sessions, ssid) == NULL) {
+ /* Need to get the original key/value */
+ res = g_hash_table_lookup_extended (seat->priv->sessions,
+ ssid,
+ (gpointer *)&orig_ssid,
+ (gpointer *)&orig_session);
+ if (! res) {
g_debug ("Session %s is not attached to seat %s", ssid, seat->priv->id);
g_set_error (error,
CK_SEAT_ERROR,
@@ -548,17 +556,23 @@ ck_seat_remove_session (CkSeat *seat,
g_signal_handlers_disconnect_by_func (session, session_activate, seat);
- ck_session_run_programs (session, "session_removed");
+ /* Remove the session from the list but don't call
+ * unref until the signal is emitted */
+ g_hash_table_steal (seat->priv->sessions, ssid);
- g_debug ("Emitting removed signal: %s", ssid);
+ ck_session_run_programs (session, "session_removed");
+ g_debug ("Emitting session-removed: %s", ssid);
g_signal_emit (seat, signals [SESSION_REMOVED], 0, ssid);
- g_hash_table_remove (seat->priv->sessions, ssid);
-
/* try to change the active session */
maybe_update_active_session (seat);
+ if (orig_session != NULL) {
+ g_object_unref (orig_session);
+ }
+ g_free (orig_ssid);
+
ret = TRUE;
out:
g_free (ssid);