From acd37cbf8578686d2e5bae64b6b4eb6d2bc5376b Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 27 Aug 2017 11:47:29 +0200
Subject: Deleted the reference to the main window in all panels.

---
 ChangeLog                              |  36 ++++
 plugins/pychrysa/Makefile.am           |   1 -
 plugins/pychrysa/gtkext/displaypanel.c |   2 +-
 plugins/pychrysa/gui/editem.c          |   1 -
 plugins/pychrysa/gui/panels/panel.c    |   3 +-
 plugins/pychrysa/pychrysa.c            |  45 -----
 plugins/pychrysa/quirks.c              | 294 ---------------------------------
 plugins/pychrysa/quirks.h              |  61 -------
 src/analysis/project.c                 |  16 +-
 src/analysis/project.h                 |   4 +-
 src/gui/core/core.c                    |   6 +-
 src/gui/core/core.h                    |   2 +-
 src/gui/core/global.c                  |  41 +++++
 src/gui/core/global.h                  |   6 +
 src/gui/core/panels.c                  |  30 ++--
 src/gui/core/panels.h                  |   4 +-
 src/gui/editor.c                       |   7 +-
 src/gui/menus/file.c                   |  39 ++---
 src/gui/panels/strings.c               |   2 +-
 src/gui/panels/welcome.c               |   8 +-
 src/main.c                             |  13 +-
 21 files changed, 143 insertions(+), 478 deletions(-)
 delete mode 100644 plugins/pychrysa/quirks.c
 delete mode 100644 plugins/pychrysa/quirks.h

diff --git a/ChangeLog b/ChangeLog
index 3fda9b4..3002ffd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,41 @@
 17-08-27  Cyrille Bagard <nocbos@gmail.com>
 
+	* plugins/pychrysa/Makefile.am:
+	Remove the 'quirks.[ch]' files from pychrysalide_la_SOURCES.
+
+	* plugins/pychrysa/gtkext/displaypanel.c:
+	* plugins/pychrysa/gui/editem.c:
+	* plugins/pychrysa/gui/panels/panel.c:
+	* plugins/pychrysa/pychrysa.c:
+	Update code.
+
+	* plugins/pychrysa/quirks.c:
+	* plugins/pychrysa/quirks.h:
+	Deleted entries: remove unused code.
+
+	* src/analysis/project.c:
+	* src/analysis/project.h:
+	* src/gui/core/core.c:
+	* src/gui/core/core.h:
+	Update code.
+
+	* src/gui/core/global.c:
+	* src/gui/core/global.h:
+	Register the main window as global variable.
+
+	* src/gui/core/panels.c:
+	* src/gui/core/panels.h:
+	Delete the reference to the main window in all panels.
+
+	* src/gui/editor.c:
+	* src/gui/menus/file.c:
+	* src/gui/panels/strings.c
+	* src/gui/panels/welcome.c:
+	* src/main.c:
+	Update code.
+
+17-08-27  Cyrille Bagard <nocbos@gmail.com>
+
 	* plugins/pychrysa/arch/vmpa.c:
 	* plugins/pychrysa/gui/editem.c:
 	* src/analysis/db/items/move.c:
diff --git a/plugins/pychrysa/Makefile.am b/plugins/pychrysa/Makefile.am
index e9798b2..fe23e99 100644
--- a/plugins/pychrysa/Makefile.am
+++ b/plugins/pychrysa/Makefile.am
@@ -7,7 +7,6 @@ pychrysalide_la_SOURCES =				\
 	helpers.h helpers.c					\
 	plugin.h plugin.c					\
 	pychrysa.h pychrysa.c				\
-	quirks.h quirks.c					\
 	weak.h weak.c
 
 pychrysalide_la_LIBADD =				\
diff --git a/plugins/pychrysa/gtkext/displaypanel.c b/plugins/pychrysa/gtkext/displaypanel.c
index aa166e5..b75d173 100644
--- a/plugins/pychrysa/gtkext/displaypanel.c
+++ b/plugins/pychrysa/gtkext/displaypanel.c
@@ -78,7 +78,7 @@ static PyObject *py_display_panel_new(PyTypeObject *type, PyObject *args, PyObje
     ret = PyArg_ParseTuple(args, "ssOs", &name, &lname, &widget, &path);
     if (!ret) Py_RETURN_NONE;
 
-    item = g_view_panel_new(get_internal_ref(), name, lname,
+    item = g_view_panel_new(name, lname,
                             GTK_WIDGET(pygobject_get(widget)), path);
 
     result = py_display_panel_from_c(G_DISPLAY_PANEL(item));
diff --git a/plugins/pychrysa/gui/editem.c b/plugins/pychrysa/gui/editem.c
index a7e9206..91f5246 100644
--- a/plugins/pychrysa/gui/editem.c
+++ b/plugins/pychrysa/gui/editem.c
@@ -32,7 +32,6 @@
 
 
 #include "../helpers.h"
-#include "../quirks.h"
 
 
 #include "../analysis/binary.h"
diff --git a/plugins/pychrysa/gui/panels/panel.c b/plugins/pychrysa/gui/panels/panel.c
index 9ca271f..72c9e7e 100644
--- a/plugins/pychrysa/gui/panels/panel.c
+++ b/plugins/pychrysa/gui/panels/panel.c
@@ -35,7 +35,6 @@
 
 #include "../editem.h"
 #include "../../helpers.h"
-#include "../../quirks.h"
 #include "../../gtkext/dockable.h"
 
 
@@ -83,7 +82,7 @@ static int py_panel_item_init(PyObject *self, PyObject *args, PyObject *kwds)
                             GTK_WIDGET(pygobject_get(widget)), startup, path);
 
     /* FIXME ? Est-ce à l'utilisateur de s'enregistrer ? */
-    register_panel_item(item, get_internal_ref(), get_main_configuration());
+    register_panel_item(item, get_main_configuration());
 
     /**
      * Si Python ne voit plus la variable représentant le panneau utilisée,
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index f4cfe90..a404c1a 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -43,7 +43,6 @@
 
 #include "helpers.h"
 #include "plugin.h"
-#include "quirks.h"
 #include "analysis/module.h"
 #include "arch/module.h"
 #include "common/module.h"
@@ -68,9 +67,6 @@ static PyObject *py_chrysalide_version(PyObject *, PyObject *);
 /* Fournit la version du greffon pour Python. */
 static PyObject *py_chrysalide_mod_version(PyObject *, PyObject *);
 
-/* Recherche et fournit si elle existe une valeur globale. */
-static PyObject *py_chrysalide_get_global_gobject(PyObject *, PyObject *);
-
 /* Détermine si l'interpréteur lancé est celui pris en compte. */
 static bool is_current_abi_suitable(void);
 
@@ -159,41 +155,6 @@ static PyObject *py_chrysalide_mod_version(PyObject *self, PyObject *args)
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : self = NULL car méthode statique.                            *
-*                args = contient la clef d'accès à un champ particulier.      *
-*                                                                             *
-*  Description : Recherche et fournit si elle existe une valeur globale.      *
-*                                                                             *
-*  Retour      : Object attaché à l'espace de référencement global ou NULL.   *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static PyObject *py_chrysalide_get_global_gobject(PyObject *self, PyObject *args)
-{
-    PyObject *result;                       /* Instance à retourner        */
-    const char *key;                        /* Désignation du champ visé   */
-    int ret;                                /* Bilan de lecture des args.  */
-    void *data;                             /* Donnée quelconque           */
-
-    ret = PyArg_ParseTuple(args, "s", &key);
-    if (!ret) Py_RETURN_NONE;
-
-    data = g_object_get_data(get_internal_ref(), key);
-    if (data == NULL) Py_RETURN_NONE;
-
-    if (!G_IS_OBJECT(data)) Py_RETURN_NONE;
-
-    result = pygobject_new(G_OBJECT(data));
-
-    return result;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
 *  Paramètres  : -                                                            *
 *                                                                             *
 *  Description : Détermine si l'interpréteur lancé est celui pris en compte.  *
@@ -348,10 +309,6 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
           METH_NOARGS,
           "mod_version(/)\n--\n\nProvide the version number of Chrysalide module for Python."
         },
-        { "get_global_gobject", py_chrysalide_get_global_gobject,
-          METH_VARARGS,
-          "get_global_gobject(key, /)\n--\n\nRetrieve if it exists a global GObject registered with the given key."
-        },
         { NULL }
 
     };
@@ -558,8 +515,6 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin, GObject *ref)
     DIR *dir;                               /* Répertoire à parcourir      */
     int ret;                                /* Bilan de préparatifs        */
 
-    define_internal_ref(ref);
-
     /* Définition des zones d'influence */
 
     dir = opendir(PLUGINS_DIR G_DIR_SEPARATOR_S "python");
diff --git a/plugins/pychrysa/quirks.c b/plugins/pychrysa/quirks.c
deleted file mode 100644
index 82ee0d5..0000000
--- a/plugins/pychrysa/quirks.c
+++ /dev/null
@@ -1,294 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * quirks.c - transmission du type Python exact aux instances de PyObject
- *
- * Copyright (C) 2012-2017 Cyrille Bagard
- *
- *  This file is part of Chrysalide.
- *
- *  Chrysalide is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  Chrysalide is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#include "quirks.h"
-
-
-
-
-#if 0
-
-//#include <pyglib.h>
-#include <pygobject.h>
-
-
-#include "helpers.h"
-
-
-
-
-
-/* Coordonnées insérées manuellement */
-typedef struct _PyGObjectData_fake
-{
-    PyTypeObject *type;                     /* Type précis pour Python     */
-    GSList *closures;                       /* Supports d'appel            */
-
-} PyGObjectData_fake;
-
-
-/* Clef d'accès réservée */
-static GQuark pygobject_instance_data_key_fake = 0;
-
-/* Clef pour l'enregistrement de l'objet Python dans l'objet GLib */
-static GQuark pygobject_wrapper_key_fake = 0;
-
-
-
-
-static void pygobject_data_free_fake(PyGObjectData_fake *data)
-{
-    //PyGILState_STATE state;                 /* Etat interne de Python      */
-    GSList *iter;                           /* Boucle de parcours          */
-    GSList *old;                            /* Sauvegarde avant libération */
-
-    //state = pyglib_gil_state_ensure();
-
-    Py_DECREF(data->type);
-
-    pyg_begin_allow_threads;
-
-    for (iter = data->closures; iter; )
-    {
-        /**
-         * On obtient le lien avant la libération via
-         * pygobject_unwatch_closure()...
-         */
-        old = iter;
-        iter = iter->next;
-
-        g_closure_invalidate((GClosure *)old->data);
-
-    }
-
-    pyg_end_allow_threads;
-
-    g_free(data);
-
-    //pyglib_gil_state_release(state);
-
-}
-
-
-
-static PyGObjectData_fake *pygobject_data_new_fake(void)
-{
-    PyGObjectData_fake *result;             /* Instance à retourner        */
-
-    result = g_new0(PyGObjectData_fake, 1);
-
-    return result;
-
-}
-
-
-static GObject *_ref = NULL;
-
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : -                                                            *
-*                                                                             *
-*  Description : Définit les éléments immuables pour toute association.       *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-void pychrysalide_init_quirks(void)
-{
-    pygobject_instance_data_key_fake = g_quark_from_static_string("PyGObject::instance-data");
-    pygobject_wrapper_key_fake = g_quark_from_static_string("PyGObject::wrapper");
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : threshold0 = seuil pour la collecte de niveau 0.             *
-*                threshold1 = seuil pour la collecte de niveau 1.             *
-*                threshold2 = seuil pour la collecte de niveau 2.             *
-*                                                                             *
-*  Description : Modifie les seuils de collecte pour le collecteur de Python. *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-void pychrysalide_set_gc_threshold(int threshold0, int threshold1, int threshold2)
-{
-    PyObject *module;                       /* Module Python "gc"          */
-    PyObject *args;                         /* Arguments pour l'appel      */
-    PyObject *value;                        /* Valeurs obtenues            */
-
-    module = PyImport_ImportModule("gc");
-
-    if (threshold0 == 0 && threshold1 == 0 && threshold2 == 0)
-    {
-        args = Py_BuildValue("()");
-        value = run_python_method(module, "disable", args);
-    }
-    else
-    {
-        args = Py_BuildValue("(iii)", threshold0, threshold1, threshold2);
-        value = run_python_method(module, "set_threshold", args);
-    }
-
-    Py_DECREF(value);
-    Py_DECREF(args);
-
-    Py_DECREF(module);
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : obj  = instance GLib crée en C.                              *
-*                type = type de l'objet Python correspond.                    *
-*                                                                             *
-*  Description : Crée l'association précise attendue par Python-GObject.      *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-void pychrysalide_set_instance_data(GObject *obj, PyTypeObject *type)
-{
-    PyGObjectData_fake *data;
-
-    data = g_object_get_qdata(obj, pygobject_instance_data_key_fake);
-
-    Py_INCREF(type);
-
-    if (data == NULL)
-    {
-        data = pygobject_data_new_fake();
-
-        /**
-         * Dans la majorité des cas, le type est retrouvé depuis un appel à
-         * PyObject_GetAttrString(), qui fournit une nouvelle référence.
-         * Donc nul besoin d'incrémenter encore cette référence.
-         */
-        data->type = type;
-
-        g_object_set_qdata_full(obj, pygobject_instance_data_key_fake,
-                                data, (GDestroyNotify)pygobject_data_free_fake);
-
-    }
-    /**
-     * On décharge l'usage du type : le compteur est déjà bien à jour si
-     * le (futur) objet est en mémoire.
-     */
-    else Py_DECREF(type);
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : obj = instance existante GLib.                               *
-*                                                                             *
-*  Description : Fournit l'instance Python d'une instance GLib, si existante. *
-*                                                                             *
-*  Retour      : Instance Python mise en place ou NULL.                       *
-*                                                                             *
-*  Remarques   : Les retours non nuls voient leur compteur incrémenté.        *
-*                                                                             *
-******************************************************************************/
-
-PyObject *pychrysalide_get_pygobject(GObject *obj)
-{
-    PyObject *result;                       /* Objet en place à renvoyer   */
-
-    result = (PyObject *)g_object_get_qdata(obj, pygobject_wrapper_key_fake);
-
-    if (result != NULL)
-        Py_INCREF(result);
-
-    return result;
-
-}
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : self = objet à initialiser (théoriquement).                  *
-*                args = arguments fournis à l'appel.                          *
-*                kwds = arguments de type key=val fournis.                    *
-*                                                                             *
-*  Description : Initialise un objet dérivé de GObject en Python.             *
-*                                                                             *
-*  Retour      : 0.                                                           *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-int pychrysalide_allow_args_for_gobjects(PyObject *self, PyObject *args, PyObject *kwds)
-{
-    return 0;
-
-}
-#endif
-
-
-
-
-
-/* Mémorisation de l'espace de référencement global */
-static GObject *_ref = NULL;
-
-
-
-/******************************************************************************
-*                                                                             *
-*  Paramètres  : ref = espace de référencement global à utiliser.             *
-*                                                                             *
-*  Description : Evite à Python d'avoir à manipuler les références internes.  *
-*                                                                             *
-*  Retour      : Adresse de l'espace de référencement global.                 *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-GObject *_get_internal_ref(GObject *ref)
-{
-    if (ref != NULL)
-    {
-        g_object_ref(ref);
-        _ref = ref;
-    }
-
-    return _ref;
-
-}
diff --git a/plugins/pychrysa/quirks.h b/plugins/pychrysa/quirks.h
deleted file mode 100644
index c0caa67..0000000
--- a/plugins/pychrysa/quirks.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/* Chrysalide - Outil d'analyse de fichiers binaires
- * quirks.h - prototypes pour la transmission du type Python exact aux instances de PyObject
- *
- * Copyright (C) 2012-2017 Cyrille Bagard
- *
- *  This file is part of Chrysalide.
- *
- *  Chrysalide is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  Chrysalide is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-
-#ifndef _PLUGINS_PYOIDA_QUIRKS_H
-#define _PLUGINS_PYOIDA_QUIRKS_H
-
-
-//#include <Python.h>
-#include <glib-object.h>
-
-
-#if 0
-/* Définit les éléments immuables pour toute association. */
-void pychrysalide_init_quirks(void);
-
-/* Modifie les seuils de collecte pour le collecteur de Python. */
-void pychrysalide_set_gc_threshold(int, int, int);
-
-/* Crée l'association précise attendue par Python-GObject. */
-void pychrysalide_set_instance_data(GObject *, PyTypeObject *);
-
-/* Fournit l'instance Python d'une instance GLib, si existante. */
-PyObject *pychrysalide_get_pygobject(GObject *);
-
-/* Initialise un objet dérivé de GObject en Python. */
-int pychrysalide_allow_args_for_gobjects(PyObject *, PyObject *, PyObject *);
-#endif
-
-
-
-/* Evite à Python d'avoir à manipuler les références internes. */
-GObject *_get_internal_ref(GObject *);
-
-
-#define define_internal_ref(r) _get_internal_ref(r)
-#define get_internal_ref() _get_internal_ref(NULL)
-
-
-
-#endif  /* _PLUGINS_PYOIDA_QUIRKS_H */
diff --git a/src/analysis/project.c b/src/analysis/project.c
index 9377247..9a10985 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -76,8 +76,6 @@ struct _GStudyProject
 {
     GObject parent;                         /* A laisser en premier        */
 
-    GObject *ref;                           /* Espace de référencement     */
-
     char *filename;                         /* Lieu d'enregistrement       */
 
     loaded_content *contents;               /* Contenus binaires chargés   */
@@ -181,15 +179,12 @@ static void g_study_project_init(GStudyProject *project)
 *                                                                             *
 ******************************************************************************/
 
-GStudyProject *g_study_project_new(GObject *ref)
+GStudyProject *g_study_project_new(void)
 {
     GStudyProject *result;                  /* Composant à retourner       */
 
     result = g_object_new(G_TYPE_STUDY_PROJECT, NULL);
 
-    g_object_ref(ref);
-    result->ref = ref;
-
     return result;
 
 }
@@ -197,8 +192,7 @@ GStudyProject *g_study_project_new(GObject *ref)
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : ref      = espace de référencements global.                  *
-*                filename = chemin d'accès au fichier à charger.              *
+*  Paramètres  : filename = chemin d'accès au fichier à charger.              *
 *                                                                             *
 *  Description : Crée un projet à partir du contenu XML d'un fichier.         *
 *                                                                             *
@@ -208,7 +202,7 @@ GStudyProject *g_study_project_new(GObject *ref)
 *                                                                             *
 ******************************************************************************/
 
-GStudyProject *g_study_project_open(GObject *ref, const char *filename)
+GStudyProject *g_study_project_open(const char *filename)
 {
     GStudyProject *result;                  /* Adresse à retourner         */
     xmlDocPtr xdoc;                         /* Structure XML chargée       */
@@ -228,7 +222,7 @@ GStudyProject *g_study_project_open(GObject *ref, const char *filename)
 
     if (!open_xml_file(filename, &xdoc, &context)) return NULL;
 
-    result = g_study_project_new(ref);
+    result = g_study_project_new();
 
     result->filename = strdup(filename);
 
@@ -866,7 +860,7 @@ GPanelItem *_setup_new_panel_item_for_binary(GStudyProject *project, GLoadedBina
     lname = g_loaded_binary_get_name(binary, true);
 
     result = g_panel_item_new(PIP_BINARY_VIEW, name, lname, selected, true, "N");
-    register_panel_item(result, project->ref, get_main_configuration());
+    register_panel_item(result, get_main_configuration());
 
     handled->items = (GPanelItem **)realloc(handled->items, ++handled->count * sizeof(GPanelItem *));
     handled->items[handled->count - 1] = result;
diff --git a/src/analysis/project.h b/src/analysis/project.h
index bf399fa..7ae3c03 100644
--- a/src/analysis/project.h
+++ b/src/analysis/project.h
@@ -68,10 +68,10 @@ typedef struct _GStudyProjectClass GStudyProjectClass;
 GType g_study_project_get_type(void);
 
 /* Crée un nouveau projet vierge. */
-GStudyProject *g_study_project_new(GObject *);
+GStudyProject *g_study_project_new(void);
 
 /* Crée un projet à partir du contenu XML d'un fichier. */
-GStudyProject *g_study_project_open(GObject *, const char *);
+GStudyProject *g_study_project_open(const char *);
 
 /* Procède à l'enregistrement d'un projet donné. */
 bool g_study_project_save(GStudyProject *, const char *);
diff --git a/src/gui/core/core.c b/src/gui/core/core.c
index d9fece5..0530953 100644
--- a/src/gui/core/core.c
+++ b/src/gui/core/core.c
@@ -34,7 +34,7 @@
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : ref = espace de référencement global.                        *
+*  Paramètres  : -                                                            *
 *                                                                             *
 *  Description : Charge les éléments graphiques de l'éditeur.                 *
 *                                                                             *
@@ -44,11 +44,11 @@
 *                                                                             *
 ******************************************************************************/
 
-bool load_all_gui_components(GObject *ref)
+bool load_all_gui_components(void)
 {
     bool result;                            /* Bilan à retourner           */
 
-    load_main_panels(ref);
+    load_main_panels();
 
     load_extra_gtk_theme();
 
diff --git a/src/gui/core/core.h b/src/gui/core/core.h
index 0dc7354..3112c44 100644
--- a/src/gui/core/core.h
+++ b/src/gui/core/core.h
@@ -34,7 +34,7 @@
 
 
 /* Charge les éléments graphiques de l'éditeur. */
-bool load_all_gui_components(GObject *);
+bool load_all_gui_components(void);
 
 /* Finalise le chargement des éléments graphiques de l'éditeur. */
 bool complete_loading_of_all_gui_components(GGenConfig *);
diff --git a/src/gui/core/global.c b/src/gui/core/global.c
index 1eb8672..b4001c6 100644
--- a/src/gui/core/global.c
+++ b/src/gui/core/global.c
@@ -25,6 +25,9 @@
 
 
 
+/* Fenêtre principale de l'éditeur */
+static GtkWindow *_editor = NULL;
+
 /* Barre de statut principale */
 static GtkStatusStack *_status = NULL;
 
@@ -47,6 +50,44 @@ G_LOCK_DEFINE_STATIC(_ci_mutex);
 
 /******************************************************************************
 *                                                                             *
+*  Paramètres  : editor = fenêtre principale à référencer.                    *
+*                                                                             *
+*  Description : Note l'adresse de la fenêtre principale de l'éditeur.        *
+*                                                                             *
+*  Retour      : -                                                            *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+void set_editor_window(GtkWindow *editor)
+{
+    _editor = editor;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : -                                                            *
+*                                                                             *
+*  Description : Fournit l'adresse de la fenêtre principale de l'éditeur.     *
+*                                                                             *
+*  Retour      : Fenêtre principale référencée.                               *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+GtkWindow *get_editor_window(void)
+{
+    return _editor;
+
+}
+
+
+/******************************************************************************
+*                                                                             *
 *  Paramètres  : status  = barre de statut à tenir informée.                  *
 *                                                                             *
 *  Description : Note l'adresse de la barre de statut principale.             *
diff --git a/src/gui/core/global.h b/src/gui/core/global.h
index 33225e3..e69f743 100644
--- a/src/gui/core/global.h
+++ b/src/gui/core/global.h
@@ -31,6 +31,12 @@
 
 
 
+/* Note l'adresse de la fenêtre principale de l'éditeur. */
+void set_editor_window(GtkWindow *);
+
+/* Fournit l'adresse de la fenêtre principale de l'éditeur. */
+GtkWindow *get_editor_window(void);
+
 /* Note l'adresse de la barre de statut principale. */
 void set_global_status(GtkStatusStack *);
 
diff --git a/src/gui/core/panels.c b/src/gui/core/panels.c
index 5a1beb1..9d11e58 100644
--- a/src/gui/core/panels.c
+++ b/src/gui/core/panels.c
@@ -49,7 +49,7 @@ static GPanelItem *_panels_list = NULL;
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : ref = espace de référencement global.                        *
+*  Paramètres  : -                                                            *
 *                                                                             *
 *  Description : Charge les principaux panneaux de l'éditeur.                 *
 *                                                                             *
@@ -59,7 +59,7 @@ static GPanelItem *_panels_list = NULL;
 *                                                                             *
 ******************************************************************************/
 
-void load_main_panels(GObject *ref)
+void load_main_panels(void)
 {
     GGenConfig *config;                     /* Configuration globale       */
     GPanelItem *item;                       /* Panneau de base à charger   */
@@ -67,34 +67,34 @@ void load_main_panels(GObject *ref)
     config = get_main_configuration();
 
     item = g_welcome_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_log_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_regedit_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_symbols_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_history_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_strings_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_glance_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_bookmarks_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_bintree_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
     item = g_error_panel_new();
-    register_panel_item(item, ref, config);
+    register_panel_item(item, config);
 
 }
 
@@ -102,7 +102,6 @@ void load_main_panels(GObject *ref)
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : item   = composant à présenter à l'affichage.                *
-*                ref    = espace de référencement global.                     *
 *                config = configuration à compléter.                          *
 *                                                                             *
 *  Description : Enregistre un panneau comme partie intégrante de l'éditeur.  *
@@ -113,15 +112,12 @@ void load_main_panels(GObject *ref)
 *                                                                             *
 ******************************************************************************/
 
-void register_panel_item(GPanelItem *item, GObject *ref, GGenConfig *config)
+void register_panel_item(GPanelItem *item, GGenConfig *config)
 {
     GEditorItem *parent;                    /* Autre version de l'élément  */
 
     parent = G_EDITOR_ITEM(item);
 
-    g_object_ref(ref);
-    parent->ref = ref;
-
     /* Enregistre correctement le tout */
     register_editor_item(parent);
     panels_list_add_tail(item, &_panels_list);
diff --git a/src/gui/core/panels.h b/src/gui/core/panels.h
index 2b55517..0c55417 100644
--- a/src/gui/core/panels.h
+++ b/src/gui/core/panels.h
@@ -35,10 +35,10 @@
 
 
 /* Charge les principaux panneaux de l'éditeur. */
-void load_main_panels(GObject *);
+void load_main_panels(void);
 
 /* Enregistre un panneau comme partie intégrante de l'éditeur. */
-void register_panel_item(GPanelItem *, GObject *, GGenConfig *);
+void register_panel_item(GPanelItem *, GGenConfig *);
 
 /* Réalise un traitement sur un panneau de l'éditeur. */
 typedef bool (* handle_panel_item_fc) (GPanelItem *, void *);
diff --git a/src/gui/editor.c b/src/gui/editor.c
index a3055c7..d44d2af 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -286,6 +286,8 @@ GtkWidget *create_editor(void)
     gtk_container_set_border_width(GTK_CONTAINER(result), 4);
     gtk_window_set_title(GTK_WINDOW(result), _("Chrysalide"));
 
+    set_editor_window(GTK_WINDOW(result));
+
     g_generic_config_get_value(get_main_configuration(), MPK_TITLE_BAR, &hide);
     gtk_window_set_hide_titlebar_when_maximized(GTK_WINDOW(result), hide);
 
@@ -345,7 +347,7 @@ GtkWidget *create_editor(void)
         //_support = init_panels2(G_CALLBACK(on_dock_item_switch), ref);
         gtk_box_pack_start(GTK_BOX(vbox1), _support, TRUE, TRUE, 0);
 
-        /* ... = */load_all_gui_components(ref);
+        /* ... = */load_all_gui_components();
 
 
     } while(0);
@@ -1379,7 +1381,8 @@ static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, gpoi
         else
             g_object_unref(G_OBJECT(binary));
 
-        g_object_unref(G_OBJECT(old_binary));
+        if (old_binary != NULL)
+            g_object_unref(G_OBJECT(old_binary));
 
         g_object_ref(G_OBJECT(widget));
         change_editor_items_current_view(GTK_DISPLAY_PANEL(widget));
diff --git a/src/gui/menus/file.c b/src/gui/menus/file.c
index c3865b6..d83f05b 100644
--- a/src/gui/menus/file.c
+++ b/src/gui/menus/file.c
@@ -28,16 +28,17 @@
 #include <i18n.h>
 
 
+#include "../core/global.h"
 #include "../../analysis/project.h"
 #include "../../gtkext/easygtk.h"
 
 
 
 /* Réagit au menu "Fichier -> Nouveau projet". */
-static void mcb_file_new_project(GtkMenuItem *, GObject *);
+static void mcb_file_new_project(GtkMenuItem *, gpointer);
 
 /* Réagit au menu "Fichier -> Ouvrir un projet". */
-static void mcb_file_open_project(GtkMenuItem *, GObject *);
+static void mcb_file_open_project(GtkMenuItem *, gpointer);
 
 /* Réagit au menu "Fichier -> Enregistrer le projet". */
 static void mcb_file_save_project(GtkMenuItem *, gpointer);
@@ -77,7 +78,7 @@ GtkWidget *build_menu_file(GObject *ref, GtkAccelGroup *accgroup)
     menubar = qck_create_menu(GTK_MENU_ITEM(result));
 
     submenuitem = qck_create_menu_item(NULL, NULL, _("New project"),
-                                       G_CALLBACK(mcb_file_new_project), ref);
+                                       G_CALLBACK(mcb_file_new_project), NULL);
     add_accelerator_to_menu_item(submenuitem, "<Ctrl>N", accgroup);
     gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
 
@@ -85,7 +86,7 @@ GtkWidget *build_menu_file(GObject *ref, GtkAccelGroup *accgroup)
     gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
 
     submenuitem = qck_create_menu_item(NULL, NULL, _("Open project"),
-                                       G_CALLBACK(mcb_file_open_project), ref);
+                                       G_CALLBACK(mcb_file_open_project), NULL);
     add_accelerator_to_menu_item(submenuitem, "<Ctrl>O", accgroup);
     gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
 
@@ -106,12 +107,12 @@ GtkWidget *build_menu_file(GObject *ref, GtkAccelGroup *accgroup)
     gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
 
     submenuitem = qck_create_menu_item(NULL, NULL, _("Save project"),
-                                       G_CALLBACK(mcb_file_save_project), ref);
+                                       G_CALLBACK(mcb_file_save_project), NULL);
     add_accelerator_to_menu_item(submenuitem, "<Ctrl>S", accgroup);
     gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
 
     submenuitem = qck_create_menu_item(NULL, NULL, _("Save project as..."),
-                                       G_CALLBACK(mcb_file_save_project_as), ref);
+                                       G_CALLBACK(mcb_file_save_project_as), NULL);
     gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
 
     submenuitem = qck_create_menu_separator();
@@ -129,7 +130,7 @@ GtkWidget *build_menu_file(GObject *ref, GtkAccelGroup *accgroup)
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : menuitem = élément de menu sélectionné.                      *
-*                ref      = adresse de l'espace de référencement global.      *
+*                unused   = adresse non utilisée ici.                         *
 *                                                                             *
 *  Description : Réagit au menu "Fichier -> Nouveau projet".                  *
 *                                                                             *
@@ -139,11 +140,11 @@ GtkWidget *build_menu_file(GObject *ref, GtkAccelGroup *accgroup)
 *                                                                             *
 ******************************************************************************/
 
-static void mcb_file_new_project(GtkMenuItem *menuitem, GObject *ref)
+static void mcb_file_new_project(GtkMenuItem *menuitem, gpointer unused)
 {
     GStudyProject *project;                 /* Nouveau projet courant      */
 
-    project = g_study_project_new(ref);
+    project = g_study_project_new();
 
     set_current_project(project);
 
@@ -155,7 +156,7 @@ static void mcb_file_new_project(GtkMenuItem *menuitem, GObject *ref)
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : menuitem = élément de menu sélectionné.                      *
-*                ref      = adresse de l'espace de référencement global.      *
+*                unused   = adresse non utilisée ici.                         *
 *                                                                             *
 *  Description : Réagit au menu "Fichier -> Ouvrir un projet".                *
 *                                                                             *
@@ -165,13 +166,13 @@ static void mcb_file_new_project(GtkMenuItem *menuitem, GObject *ref)
 *                                                                             *
 ******************************************************************************/
 
-static void mcb_file_open_project(GtkMenuItem *menuitem, GObject *ref)
+static void mcb_file_open_project(GtkMenuItem *menuitem, gpointer unused)
 {
     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"), GTK_WINDOW(ref),
+    dialog = gtk_file_chooser_dialog_new(_("Open a project"), get_editor_window(),
                                          GTK_FILE_CHOOSER_ACTION_OPEN,
                                          _("_Cancel"), GTK_RESPONSE_CANCEL,
                                          _("_Open"), GTK_RESPONSE_ACCEPT,
@@ -187,7 +188,7 @@ static void mcb_file_open_project(GtkMenuItem *menuitem, GObject *ref)
     {
         filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
 
-        project = g_study_project_open(ref, filename);
+        project = g_study_project_open(filename);
 
         if (project != NULL)
         {
@@ -208,7 +209,7 @@ static void mcb_file_open_project(GtkMenuItem *menuitem, GObject *ref)
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : menuitem = élément de menu sélectionné.                      *
-*                data     = adresse de l'espace de référencement global.      *
+*                unused   = adresse non utilisée ici.                         *
 *                                                                             *
 *  Description : Réagit au menu "Fichier -> Enregistrer le projet".           *
 *                                                                             *
@@ -218,7 +219,7 @@ static void mcb_file_open_project(GtkMenuItem *menuitem, GObject *ref)
 *                                                                             *
 ******************************************************************************/
 
-static void mcb_file_save_project(GtkMenuItem *menuitem, gpointer data)
+static void mcb_file_save_project(GtkMenuItem *menuitem, gpointer unused)
 {
     GStudyProject *project;                 /* Projet courant              */
 
@@ -231,7 +232,7 @@ static void mcb_file_save_project(GtkMenuItem *menuitem, gpointer data)
     }
 
     else
-        mcb_file_save_project_as(menuitem, data);
+        mcb_file_save_project_as(menuitem, NULL);
 
 }
 
@@ -239,7 +240,7 @@ static void mcb_file_save_project(GtkMenuItem *menuitem, gpointer data)
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : menuitem = élément de menu sélectionné.                      *
-*                data     = adresse de l'espace de référencement global.      *
+*                unused   = adresse non utilisée ici.                         *
 *                                                                             *
 *  Description : Réagit au menu "Fichier -> Enregistrer le projet sous...".   *
 *                                                                             *
@@ -249,13 +250,13 @@ static void mcb_file_save_project(GtkMenuItem *menuitem, gpointer data)
 *                                                                             *
 ******************************************************************************/
 
-static void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer data)
+static void mcb_file_save_project_as(GtkMenuItem *menuitem, gpointer unused)
 {
     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..."), GTK_WINDOW(data),
+    dialog = gtk_file_chooser_dialog_new(_("Save the project as..."), get_editor_window(),
                                          GTK_FILE_CHOOSER_ACTION_SAVE,
                                          _("_Cancel"), GTK_RESPONSE_CANCEL,
                                          _("_Save"), GTK_RESPONSE_ACCEPT,
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index c9d971e..6ae44b1 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -1054,7 +1054,7 @@ 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_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
+    ref = G_OBJECT(get_editor_window());//g_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
 
     dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), binary, instr, true);
 
diff --git a/src/gui/panels/welcome.c b/src/gui/panels/welcome.c
index 44ff517..8ae1667 100644
--- a/src/gui/panels/welcome.c
+++ b/src/gui/panels/welcome.c
@@ -37,6 +37,7 @@
 
 
 #include "panel-int.h"
+#include "../core/global.h"
 #include "../../analysis/project.h"
 #include "../../common/cpp.h"
 #include "../../common/io.h"
@@ -468,7 +469,7 @@ 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_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
+    ref = G_OBJECT(get_editor_window());//g_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
 
     item = GTK_MENU_ITEM(g_object_get_data(ref, "mnu_project_add_binary"));
 
@@ -594,7 +595,6 @@ static void on_row_activated_for_projects(GtkTreeView *treeview, GtkTreePath *pa
     GtkTreeIter iter;                       /* Point de la consultation    */
     gboolean valid;                         /* Validité de l'entrée        */
     gchar *filename;                        /* Chemin d'accès au projet    */
-    GObject *ref;                           /* Espace de référencements    */
     GStudyProject *project;                 /* Nouveau projet à ouvrir     */
 
     model = gtk_tree_view_get_model(treeview);
@@ -605,9 +605,7 @@ static void on_row_activated_for_projects(GtkTreeView *treeview, GtkTreePath *pa
 
         if (valid)
         {
-            ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(panel));
-
-            project = g_study_project_open(ref, filename);
+            project = g_study_project_open(filename);
 
             if (project != NULL)
             {
diff --git a/src/main.c b/src/main.c
index 46eb3e8..43fa5d3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,11 +60,6 @@ static int open_binaries(char **, int);
 
 
 
-/* Espace de référencement global. // FIXME à déplacer */
-static GObject *_ref = NULL;
-
-
-
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : name = nom du programme en question.                         *
@@ -251,8 +246,6 @@ int main(int argc, char **argv)
     editor = create_editor();
     if (editor == NULL) goto failed_to_load_editor;
 
-    _ref = G_OBJECT(editor);
-
     if (!batch_mode)
         gtk_widget_show_now(editor);
 
@@ -288,7 +281,7 @@ int main(int argc, char **argv)
         g_idle_add((GSourceFunc)load_last_project, config);
 
     else
-        set_current_project(g_study_project_new(_ref));
+        set_current_project(g_study_project_new());
 
     /* Exécution du programme */
 
@@ -341,8 +334,8 @@ static gboolean load_last_project(GGenConfig *cfg)
     if (!g_generic_config_get_value(cfg, MPK_LAST_PROJECT, &filename))
         filename = NULL;
 
-    if (filename == NULL) project = g_study_project_new(_ref);
-    else project = g_study_project_open(_ref, filename);
+    if (filename == NULL) project = g_study_project_new();
+    else project = g_study_project_open(filename);
 
     set_current_project(project);
 
-- 
cgit v0.11.2-87-g4458