[gnome-software: 2/15] gs-common: Add fallback copy of g_clear_signal_handler()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 2/15] gs-common: Add fallback copy of g_clear_signal_handler()
- Date: Tue, 3 Aug 2021 15:19:41 +0000 (UTC)
commit 2e4703c96a834ac3de8885d688a605ac2413bbbd
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Jul 23 17:32:40 2021 +0100
gs-common: Add fallback copy of g_clear_signal_handler()
It was added to GLib in 2.62, but we only depend on 2.55. Until our GLib
dependency is bumped, carry an internal copy of the macro, since it’s
quite useful.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
src/gs-common.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/src/gs-common.h b/src/gs-common.h
index ebc5d0952..cc27dbcb6 100644
--- a/src/gs-common.h
+++ b/src/gs-common.h
@@ -56,4 +56,21 @@ gboolean gs_utils_split_time_difference (gint64 unix_time_seconds,
gint *out_months_ago,
gint *out_years_ago);
+#if !GLIB_CHECK_VERSION(2, 62, 0)
+
+#define g_clear_signal_handler(handler_id_ptr, instance) \
+ G_STMT_START { \
+ gpointer const _instance = (instance); \
+ gulong *const _handler_id_ptr = (handler_id_ptr); \
+ const gulong _handler_id = *_handler_id_ptr; \
+ \
+ if (_handler_id > 0) \
+ { \
+ *_handler_id_ptr = 0; \
+ g_signal_handler_disconnect (_instance, _handler_id); \
+ } \
+ } G_STMT_END \
+
+#endif
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]