From 43dc21cc3239bd5c82f9ab4483ecd5b4cdfb3f0f Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Fri, 11 Nov 2016 22:33:53 +0100
Subject: Improved the way display panel binaries are tracked.

---
 ChangeLog                    | 11 +++++++++++
 src/gtkext/gtkdisplaypanel.c |  2 +-
 src/gui/editem.c             |  4 +++-
 src/gui/editor.c             |  2 ++
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0ef2a2..f973490 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 16-11-09  Cyrille Bagard <nocbos@gmail.com>
 
+	* src/gtkext/gtkdisplaypanel.c:
+	Improve the way display panel binaries are tracked.
+
+	* src/gui/editem.c:
+	Update code. Increase the reference counter for the current binary.
+
+	* src/gui/editor.c:
+	Update code.
+
+16-11-09  Cyrille Bagard <nocbos@gmail.com>
+
 	* plugins/pychrysa/arch/vmpa.c:
 	* plugins/pychrysa/gtkext/Makefile.am:
 	* plugins/pychrysa/gtkext/bufferview.c:
diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c
index c237924..0beeb1c 100644
--- a/src/gtkext/gtkdisplaypanel.c
+++ b/src/gtkext/gtkdisplaypanel.c
@@ -858,7 +858,7 @@ static void on_view_panel_binary_display_change(GLoadedBinary *binary, BinaryVie
 
 GLoadedBinary *gtk_display_panel_get_binary(const GtkDisplayPanel *panel)
 {
-    /* TODO : ref */
+    g_objet_ref(G_OBJECT(binary));
 
     return panel->binary;
 
diff --git a/src/gui/editem.c b/src/gui/editem.c
index a2d1210..5bb3045 100644
--- a/src/gui/editem.c
+++ b/src/gui/editem.c
@@ -250,7 +250,8 @@ void change_editor_items_current_binary(GObject *ref, GLoadedBinary *binary)
     GEditorItem *iter;                      /* Boucle de parcours          */
     GEditorItemClass *klass;                /* Classe correspondante       */
 
-    g_object_set_data(ref, "current_binary", binary);
+    g_objet_ref(G_OBJECT(binary));
+    g_object_set_data_full(ref, "current_binary", binary, g_object_unref);
 
     editem_list_for_each(iter, _editem_list)
     {
@@ -329,6 +330,7 @@ static void start_moving_to_address_in_view_panel(GtkDisplayPanel *panel, const
 
         binary = gtk_display_panel_get_binary(panel);
         g_loaded_binary_add_to_collection(binary, G_DB_ITEM(move));
+        g_objet_unref(G_OBJECT(binary));
 
     }
 
diff --git a/src/gui/editor.c b/src/gui/editor.c
index 736c6f6..b1d5ab1 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -1217,6 +1217,8 @@ static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, GObj
 
         //notify_panels_of_view_change(GTK_DISPLAY_PANEL(widget), false);
 
+        g_objet_unref(G_OBJECT(binary));
+
     }
 
 }
-- 
cgit v0.11.2-87-g4458