diff options
author | Eric Koegel <eric.koegel@gmail.com> | 2017-05-05 15:26:22 +0300 |
---|---|---|
committer | Eric Koegel <eric.koegel@gmail.com> | 2017-05-06 02:40:09 +0300 |
commit | 17552aa8493b09094eecfc37afb346e8470e7dbc (patch) | |
tree | 767ef1315e9abd72801bf2703a33d63c5c0a1e14 | |
parent | d6acb738f3b28a2456d911dfbd69a140b3477967 (diff) | |
download | ConsoleKit2-17552aa8493b09094eecfc37afb346e8470e7dbc.tar.gz |
Fix ref count warning messages in ck-inhibit
Commit 635648deede5a4 has the side effect of causing a warning
message when the uninhibit signals are sent during the finalize
phase as we can't take a reference there. So we'll need to check
to see if the object was destroyed before sending each emit message.
Additionally, in the manager, move the disconnect signal handler up
since we'll be removing that inhibit anyway.
This should fix:
https://github.com/ConsoleKit2/ConsoleKit2/issues/92
https://github.com/ConsoleKit2/ConsoleKit2/issues/87
-rw-r--r-- | src/ck-inhibit-manager.c | 2 | ||||
-rw-r--r-- | src/ck-inhibit.c | 20 |
2 files changed, 8 insertions, 14 deletions
diff --git a/src/ck-inhibit-manager.c b/src/ck-inhibit-manager.c index aa9d3c0..19bffc1 100644 --- a/src/ck-inhibit-manager.c +++ b/src/ck-inhibit-manager.c @@ -263,10 +263,10 @@ ck_inhibit_manager_remove_lock (CkInhibitManager *manager, /* Found it! Remove it from the list and unref the object */ priv->inhibit_list = g_list_remove (priv->inhibit_list, inhibit); - ck_inhibit_remove_lock (inhibit); g_signal_handlers_disconnect_by_func (inhibit, G_CALLBACK (cb_changed_event), manager); + ck_inhibit_remove_lock (inhibit); g_object_unref (inhibit); return TRUE; } diff --git a/src/ck-inhibit.c b/src/ck-inhibit.c index b79ce98..4d7c872 100644 --- a/src/ck-inhibit.c +++ b/src/ck-inhibit.c @@ -337,48 +337,42 @@ emit_final_uninhibit_signals (CkInhibit *inhibit) return; } - /* keep a ref to ourselves so we don't get destroyed before - * all the messages are sent */ - g_object_ref (inhibit); - priv = CK_INHIBIT_GET_PRIVATE (inhibit); - if (priv->inhibitors[CK_INHIBIT_EVENT_SHUTDOWN]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_SHUTDOWN]) { priv->inhibitors[CK_INHIBIT_EVENT_SHUTDOWN] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_SHUTDOWN, FALSE); } - if (priv->inhibitors[CK_INHIBIT_EVENT_SUSPEND]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_SUSPEND]) { priv->inhibitors[CK_INHIBIT_EVENT_SUSPEND] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_SUSPEND, FALSE); } - if (priv->inhibitors[CK_INHIBIT_EVENT_IDLE]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_IDLE]) { priv->inhibitors[CK_INHIBIT_EVENT_IDLE] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_IDLE, FALSE); } - if (priv->inhibitors[CK_INHIBIT_EVENT_POWER_KEY]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_POWER_KEY]) { priv->inhibitors[CK_INHIBIT_EVENT_POWER_KEY] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_POWER_KEY, FALSE); } - if (priv->inhibitors[CK_INHIBIT_EVENT_SUSPEND_KEY]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_SUSPEND_KEY]) { priv->inhibitors[CK_INHIBIT_EVENT_SUSPEND_KEY] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_SUSPEND_KEY, FALSE); } - if (priv->inhibitors[CK_INHIBIT_EVENT_HIBERNATE_KEY]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_HIBERNATE_KEY]) { priv->inhibitors[CK_INHIBIT_EVENT_HIBERNATE_KEY] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_HIBERNATE_KEY, FALSE); } - if (priv->inhibitors[CK_INHIBIT_EVENT_LID_SWITCH]) { + if (CK_IS_INHIBIT (inhibit) && priv->inhibitors[CK_INHIBIT_EVENT_LID_SWITCH]) { priv->inhibitors[CK_INHIBIT_EVENT_LID_SWITCH] = FALSE; g_signal_emit(G_OBJECT (inhibit), __signals[SIG_CHANGED_EVENT], 0, priv->mode, CK_INHIBIT_EVENT_LID_SWITCH, FALSE); } - - g_object_unref (inhibit); } /* |