diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2015-05-10 09:55:11 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2015-05-10 09:55:11 +0300 |
commit | ba502c8537841a9b40dc2b6b7f17a914d81ed6d5 (patch) | |
tree | 0c50457fbfac023d6aa5fd755add53425c0cafff | |
parent | eb16197fb56273331e189f8b30d7e9eed3be998e (diff) | |
download | ConsoleKit2-ba502c8537841a9b40dc2b6b7f17a914d81ed6d5.tar.gz |
CkSession: Fix error handling in dbus_activate
Since we set an initial error message in the event g_signal_emit
isn't handled for the session activate signal, we need to keep
track of that error message. Additionally, that signal call may
return a different error message such as the session is
already activate on the seat so we need to keep track of both since
we'll need to free the memory associated with them.
-rw-r--r-- | src/ck-session.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ck-session.c b/src/ck-session.c index f8dd14b..6836146 100644 --- a/src/ck-session.c +++ b/src/ck-session.c @@ -449,7 +449,8 @@ static gboolean dbus_activate (ConsoleKitSession *cksession, GDBusMethodInvocation *context) { - GError *error; + GError *error = NULL; + GError *initial_error; CkSession *session = CK_SESSION (cksession); TRACE (); @@ -460,6 +461,10 @@ dbus_activate (ConsoleKitSession *cksession, g_set_error (&error, CK_SESSION_ERROR, CK_SESSION_ERROR_NOT_SUPPORTED, _("Activate signal not handeled. Session not attached to seat, or the seat doesn't support activation changes")); + /* keep track of the starting error because the call to g_signal_emit + * may change it and we still need to free it */ + initial_error = error; + g_signal_emit (session, signals [ACTIVATE], 0, context, &error); if (error != NULL) { /* if the signal is not handled then either: @@ -478,9 +483,14 @@ dbus_activate (ConsoleKitSession *cksession, default: throw_error (context, CK_SESSION_ERROR_GENERAL, error->message); } + + g_clear_error (&error); + g_clear_error (&initial_error); return TRUE; } + g_clear_error (&initial_error); + console_kit_session_complete_activate (cksession, context); return TRUE; } |