diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-12-26 21:33:10 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-12-26 21:33:19 (GMT) |
commit | 67b4887317b7394d63b543aa48cb368406374103 (patch) | |
tree | 7d05c391f47f1971d11115539a7306055385d01a /src | |
parent | 181e3a9a8819ba50c74f4864c0fca111e375aa5e (diff) |
Handled swapping closures when signaling to the main thread.
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/project.c | 27 | ||||
-rw-r--r-- | src/analysis/project.h | 3 | ||||
-rw-r--r-- | src/glibext/signal.c | 13 | ||||
-rw-r--r-- | src/glibext/signal.h | 12 | ||||
-rw-r--r-- | src/gui/menus/project.c | 4 |
5 files changed, 27 insertions, 32 deletions
diff --git a/src/analysis/project.c b/src/analysis/project.c index 66f6b0f..cb1c70a 100644 --- a/src/analysis/project.c +++ b/src/analysis/project.c @@ -523,9 +523,9 @@ void ack_loaded_binary(GBinaryLoader *loader, GStudyProject *project) if (binary != NULL) { - g_signal_connect_to_main(binary, "disassembly-done", - G_CALLBACK(g_study_project_add_loaded_binary), project, - g_cclosure_marshal_VOID__VOID); + g_signal_connect_to_main_swapped(binary, "disassembly-done", + G_CALLBACK(g_study_project_attach_binary), project, + g_cclosure_marshal_VOID__VOID); g_loaded_binary_analyse(binary); @@ -536,27 +536,6 @@ void ack_loaded_binary(GBinaryLoader *loader, GStudyProject *project) /****************************************************************************** * * -* Paramètres : binary = élément binaire tout juste désassemblé. * -* project = projet dont le contenu est à compléter. * -* * -* Description : Assure l'intégration d'un élément binaire dans un projet. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_study_project_add_loaded_binary(GLoadedBinary *binary, GStudyProject *project) -{ - /* FIXME : remplacer cette fonction par un "swap" */ - g_study_project_attach_binary(project, binary); - -} - - -/****************************************************************************** -* * * Paramètres : widget = composant d'affichage nouvellement porté à l'écran. * * event = informations liées à l'événement. * * binary = fichier binaire à associer au projet actuel. * diff --git a/src/analysis/project.h b/src/analysis/project.h index b331b1f..8288384 100644 --- a/src/analysis/project.h +++ b/src/analysis/project.h @@ -99,9 +99,6 @@ GBinContent *g_study_project_find_binary_content_by_hash(GStudyProject *, const /* Acquitte la fin d'un chargement différé et complet. */ void ack_loaded_binary(GBinaryLoader *, GStudyProject *); -/* Assure l'intégration d'un élément binaire dans un projet. */ -void g_study_project_add_loaded_binary(GLoadedBinary *, GStudyProject *); - /* Attache un fichier donné à un projet donné. */ void g_study_project_attach_binary(GStudyProject *, GLoadedBinary *); 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) diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c index 2930a95..c46c017 100644 --- a/src/gui/menus/project.c +++ b/src/gui/menus/project.c @@ -228,8 +228,8 @@ static void mcb_project_add_shellcode(GtkMenuItem *menuitem, GMenuBar *bar) if (binary != NULL) { - g_signal_connect(binary, "disassembly-done", - G_CALLBACK(g_study_project_add_loaded_binary), get_current_project()); + g_signal_connect_swapped(binary, "disassembly-done", + G_CALLBACK(g_study_project_attach_binary), get_current_project()); g_loaded_binary_analyse(binary); } |