summaryrefslogtreecommitdiff
path: root/src/glibext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-26 21:33:10 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-26 21:33:19 (GMT)
commit67b4887317b7394d63b543aa48cb368406374103 (patch)
tree7d05c391f47f1971d11115539a7306055385d01a /src/glibext
parent181e3a9a8819ba50c74f4864c0fca111e375aa5e (diff)
Handled swapping closures when signaling to the main thread.
Diffstat (limited to 'src/glibext')
-rw-r--r--src/glibext/signal.c13
-rw-r--r--src/glibext/signal.h12
2 files changed, 22 insertions, 3 deletions
diff --git a/src/glibext/signal.c b/src/glibext/signal.c
index 654e696..e0a59c0 100644
--- a/src/glibext/signal.c
+++ b/src/glibext/signal.c
@@ -154,6 +154,8 @@ static void carry_signal_to_main_thread(gsignal_wrapper_info *info, ...)
* signal = identification du signal à réceptionner. *
* handler = fonction C servant de réceptacle. *
* data = éventuelle donnée de l'utilisateur à ajouter. *
+* marshal = précise la fonction de transfert des arguments. *
+* flags = fournit quelques indications supplémentaires. *
* *
* Description : Reproduit le comportement de la fonction g_signal_connect(). *
* *
@@ -163,7 +165,7 @@ static void carry_signal_to_main_thread(gsignal_wrapper_info *info, ...)
* *
******************************************************************************/
-gulong g_signal_connect_to_main(gpointer instance, const gchar *signal, GCallback handler, gpointer data, GClosureMarshal marshal)
+gulong _g_signal_connect_to_main(gpointer instance, const gchar *signal, GCallback handler, gpointer data, GClosureMarshal marshal, GConnectFlags flags)
{
guint signal_id; /* Identifiant du signal visé */
GSignalQuery query; /* Information sur le signal */
@@ -181,7 +183,14 @@ gulong g_signal_connect_to_main(gpointer instance, const gchar *signal, GCallbac
info->instance = instance;
- info->closure = g_cclosure_new(handler, data, NULL);
+ if (flags & G_CONNECT_SWAPPED)
+ info->closure = g_cclosure_new_swap(handler, data, NULL);
+ else
+ info->closure = g_cclosure_new(handler, data, NULL);
+
+ g_closure_ref(info->closure);
+ g_closure_sink(info->closure);
+
g_closure_set_marshal(info->closure, marshal);
info->return_type = query.return_type;
diff --git a/src/glibext/signal.h b/src/glibext/signal.h
index 0c8e8a0..ba12a7b 100644
--- a/src/glibext/signal.h
+++ b/src/glibext/signal.h
@@ -27,11 +27,21 @@
#include <glib-object.h>
#include <gobject/gclosure.h>
+#include <glib/gdataset.h>
+#include <glib/glist.h>
+#include <gobject/gsignal.h>
/* Reproduit le comportement de la fonction g_signal_connect(). */
-gulong g_signal_connect_to_main(gpointer, const gchar *, GCallback, gpointer, GClosureMarshal);
+gulong _g_signal_connect_to_main(gpointer, const gchar *, GCallback, gpointer, GClosureMarshal, GConnectFlags);
+
+
+#define g_signal_connect_to_main(instance, signal, handler, data, marshal) \
+ _g_signal_connect_to_main(instance, signal, handler, data, marshal, 0)
+
+#define g_signal_connect_to_main_swapped(instance, signal, handler, data, marshal) \
+ _g_signal_connect_to_main(instance, signal, handler, data, marshal, G_CONNECT_SWAPPED)