summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-06-24 19:16:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-06-24 19:16:23 (GMT)
commitd614d4b09230411455ed07aac289025a55633da8 (patch)
treec94a14097f9e97b21e5780852589d167ca68ba59 /src
parentafc9e5510d9520928480042a56a193dd71db6a01 (diff)
Referenced all accesses to the main window.
Diffstat (limited to 'src')
-rw-r--r--src/gui/core/global.c14
-rw-r--r--src/gui/editor.c4
-rw-r--r--src/gui/menus/binary.c28
-rw-r--r--src/gui/menus/file.c16
-rw-r--r--src/gui/panels/strings.c8
-rw-r--r--src/gui/panels/welcome.c4
-rw-r--r--src/main.c2
7 files changed, 64 insertions, 12 deletions
diff --git a/src/gui/core/global.c b/src/gui/core/global.c
index bfc2426..7b6afc9 100644
--- a/src/gui/core/global.c
+++ b/src/gui/core/global.c
@@ -63,8 +63,13 @@ G_LOCK_DEFINE_STATIC(_cv_mutex);
void set_editor_window(GtkWindow *editor)
{
+ g_clear_object(&_editor);
+
_editor = editor;
+ if (editor != NULL)
+ g_object_ref(G_OBJECT(editor));
+
}
@@ -82,7 +87,14 @@ void set_editor_window(GtkWindow *editor)
GtkWindow *get_editor_window(void)
{
- return _editor;
+ GtkWindow *result; /* Instance à retourner */
+
+ result = _editor;
+
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
+
+ return result;
}
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 627df95..f2807bf 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -222,6 +222,8 @@ GtkWidget *create_editor(void)
gtk_container_set_border_width(GTK_CONTAINER(result), 4);
gtk_window_set_title(GTK_WINDOW(result), _("Chrysalide"));
+ g_object_ref_sink(G_OBJECT(result));
+
set_editor_window(GTK_WINDOW(result));
g_generic_config_get_value(get_main_configuration(), MPK_TITLE_BAR, &hide);
@@ -411,6 +413,8 @@ static void on_destroy_editor(GtkWidget *widget, GObject *ref)
/* On évite de mettre à jour un affichage disparu... */
register_project_change_notification(NULL);
+ set_editor_window(NULL);
+
/* Si la boucle principale est bien lancée, on en sort ! */
if (gtk_main_level() > 0)
gtk_main_quit();
diff --git a/src/gui/menus/binary.c b/src/gui/menus/binary.c
index 3a143da..cb131d7 100644
--- a/src/gui/menus/binary.c
+++ b/src/gui/menus/binary.c
@@ -212,13 +212,16 @@ void update_access_for_view_in_menu_binary(GLoadedPanel *new)
static void mcb_binary_entry_points(GtkMenuItem *menuitem, GMenuBar *bar)
{
GLoadedBinary *binary; /* Binaire présenté à l'écran */
+ GtkWindow *editor; /* Fenêtre graphique principale*/
GtkWidget *dialog; /* Boîte de dialogue à montrer */
vmpa2t *addr; /* Adresse de destination */
GLoadedPanel *panel; /* Afficheur effectif de code */
binary = G_LOADED_BINARY(get_current_content());
- dialog = create_gotox_dialog_for_entry_points(get_editor_window(), binary);
+ editor = get_editor_window();
+
+ dialog = create_gotox_dialog_for_entry_points(editor, binary);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
{
@@ -237,6 +240,8 @@ static void mcb_binary_entry_points(GtkMenuItem *menuitem, GMenuBar *bar)
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(editor));
+
g_object_unref(G_OBJECT(binary));
}
@@ -278,12 +283,15 @@ static void mcb_binary_storage(GtkMenuItem *menuitem, GMenuBar *bar)
{
GLoadedBinary *binary; /* Edition courante */
GtkBuilder *builder; /* Constructeur utilisé */
+ GtkWindow *editor; /* Fenêtre graphique principale*/
GtkWidget *dialog; /* Boîte de dialogue à montrer */
gint ret; /* Retour de confirmation */
binary = G_LOADED_BINARY(get_current_content());
- dialog = create_storage_dialog(binary, get_editor_window(), &builder);
+ editor = get_editor_window();
+
+ dialog = create_storage_dialog(binary, editor, &builder);
ret = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -294,6 +302,8 @@ static void mcb_binary_storage(GtkMenuItem *menuitem, GMenuBar *bar)
g_object_unref(G_OBJECT(builder));
+ g_object_unref(G_OBJECT(editor));
+
g_object_unref(G_OBJECT(binary));
}
@@ -315,10 +325,15 @@ static void mcb_binary_storage(GtkMenuItem *menuitem, GMenuBar *bar)
static void mcb_binary_export_disass(GtkMenuItem *menuitem, gpointer unused)
{
GLoadedBinary *binary; /* Edition courante */
+ GtkWindow *editor; /* Fenêtre graphique principale*/
binary = G_LOADED_BINARY(get_current_content());
- run_export_assistant(binary, get_editor_window());
+ editor = get_editor_window();
+
+ run_export_assistant(binary, editor);
+
+ g_object_unref(G_OBJECT(editor));
g_object_unref(G_OBJECT(binary));
@@ -342,12 +357,17 @@ static void mcb_binary_export_graph(GtkMenuItem *menuitem, gpointer unused)
{
GtkGraphDisplay *panel; /* Panneau de code courant */
GLoadedBinary *binary; /* Edition courante */
+ GtkWindow *editor; /* Fenêtre graphique principale*/
binary = G_LOADED_BINARY(get_current_content());
panel = GTK_GRAPH_DISPLAY(get_current_view());
- run_graph_export_assistant(binary, panel, get_editor_window());
+ editor = get_editor_window();
+
+ run_graph_export_assistant(binary, panel, editor);
+
+ g_object_unref(G_OBJECT(editor));
g_object_unref(G_OBJECT(panel));
diff --git a/src/gui/menus/file.c b/src/gui/menus/file.c
index 469aa41..3008635 100644
--- a/src/gui/menus/file.c
+++ b/src/gui/menus/file.c
@@ -164,11 +164,14 @@ static void mcb_file_new_project(GtkMenuItem *menuitem, gpointer unused)
static void mcb_file_open_project(GtkMenuItem *menuitem, gpointer unused)
{
+ GtkWindow *editor; /* Fenêtre graphique principale*/
GtkWidget *dialog; /* Boîte à afficher */
GStudyProject *project; /* Projet chargé */
gchar *filename; /* Nom du fichier à intégrer */
- dialog = gtk_file_chooser_dialog_new(_("Open a project"), get_editor_window(),
+ editor = get_editor_window();
+
+ dialog = gtk_file_chooser_dialog_new(_("Open a project"), editor,
GTK_FILE_CHOOSER_ACTION_OPEN,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Open"), GTK_RESPONSE_ACCEPT,
@@ -200,6 +203,8 @@ static void mcb_file_open_project(GtkMenuItem *menuitem, gpointer unused)
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(editor));
+
}
@@ -251,11 +256,14 @@ void mcb_file_save_project(GtkMenuItem *menuitem, gpointer unused)
static void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer unused)
{
+ GtkWindow *editor; /* Fenêtre graphique principale*/
GtkWidget *dialog; /* Boîte à afficher */
GStudyProject *project; /* Projet courant */
gchar *filename; /* Nom du fichier à intégrer */
- dialog = gtk_file_chooser_dialog_new(_("Save the project as..."), get_editor_window(),
+ editor = get_editor_window();
+
+ dialog = gtk_file_chooser_dialog_new(_("Save the project as..."), editor,
GTK_FILE_CHOOSER_ACTION_SAVE,
_("_Cancel"), GTK_RESPONSE_CANCEL,
_("_Save"), GTK_RESPONSE_ACCEPT,
@@ -282,6 +290,8 @@ static void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer unused)
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(editor));
+
}
@@ -306,4 +316,6 @@ static void mcb_file_quit(GtkMenuItem *menuitem, gpointer unused)
gtk_window_close(editor);
+ g_object_unref(G_OBJECT(editor));
+
}
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index 7fd0ffc..a99b40c 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -1269,7 +1269,7 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa
const mrange_t *range; /* Couverture en mémoire */
GArchProcessor *proc; /* Processeur de l'architecture*/
GArchInstruction *instr; /* Point de croisements */
- GObject *ref; /* Espace de référencements */
+ GtkWindow *editor; /* Fenêtre graphique principale*/
GtkWidget *dialog; /* Boîte de dialogue à montrer */
vmpa2t *addr; /* Adresse de destination */
GLoadedPanel *display; /* Afficheur effectif de code */
@@ -1287,9 +1287,9 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa
*/
instr = g_arch_processor_find_instr_by_address(proc, get_mrange_addr(range));
- ref = G_OBJECT(get_editor_window());//g_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
+ editor = get_editor_window();
- dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), panel->binary, instr, true);
+ dialog = create_gotox_dialog_for_cross_references(editor, panel->binary, instr, true);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
{
@@ -1308,6 +1308,8 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(editor));
+
if (instr != NULL)
g_object_unref(G_OBJECT(instr));
diff --git a/src/gui/panels/welcome.c b/src/gui/panels/welcome.c
index 6812125..63811a9 100644
--- a/src/gui/panels/welcome.c
+++ b/src/gui/panels/welcome.c
@@ -463,10 +463,12 @@ static void on_new_binary_clicked(GtkButton *button, GWelcomePanel *panel)
GObject *ref; /* Espace de référencements */
GtkMenuItem *item; /* Elément de menu simulé */
- ref = G_OBJECT(get_editor_window());//g_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
+ ref = G_OBJECT(get_editor_window());
item = GTK_MENU_ITEM(g_object_get_data(ref, "mnu_project_add_binary"));
+ g_object_unref(ref);
+
gtk_menu_item_activate(item);
}
diff --git a/src/main.c b/src/main.c
index e5a964e..3b05581 100644
--- a/src/main.c
+++ b/src/main.c
@@ -411,7 +411,7 @@ int main(int argc, char **argv)
exit_all_plugins();
if (!batch_mode)
- gtk_widget_destroy(editor);
+ g_object_unref(G_OBJECT(editor));
failed_to_load_editor: