File bijiben-memory-leak-fixes.patch of Package bijiben

From e3eeef938872031fa67226ca2fe385f9fb81c636 Mon Sep 17 00:00:00 2001
From: Isaque Galdino <igaldino@gmail.com>
Date: Mon, 16 Apr 2018 13:11:47 -0300
Subject: settings: Fix memory leak

BjbSettings is self referencing due to g_setting_bind.

This patch removes that binding and add code to load settings.
---
 src/bjb-settings.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/bjb-settings.c b/src/bjb-settings.c
index a8af12e..b1ce7a5 100644
--- a/src/bjb-settings.c
+++ b/src/bjb-settings.c
@@ -115,26 +115,31 @@ bjb_settings_set_property (GObject      *object,
                            GParamSpec   *pspec)
 {
   BjbSettings *self = BJB_SETTINGS (object);
+  GSettings   *settings = G_SETTINGS (object);
 
   switch (prop_id)
   {
     case PROP_USE_SYSTEM_FONT:
       self->use_system_font = g_value_get_boolean (value);
+      g_settings_set_boolean (settings, "use-system-font", self->use_system_font);
       break;
 
     case PROP_FONT:
       g_free (self->font);
       self->font = g_value_dup_string (value);
+      g_settings_set_string (settings, "font", self->font);
       break;
 
     case PROP_COLOR:
       g_free (self->color);
       self->color = g_value_dup_string (value);
+      g_settings_set_string (settings, "color", self->color);
       break;
 
     case PROP_PRIMARY:
       g_free (self->primary);
       self->primary = g_value_dup_string (value);
+      g_settings_set_string (settings, "default-location", self->primary);
       break;
 
     default:
@@ -156,22 +161,10 @@ bjb_settings_constructed (GObject *object)
   settings = G_SETTINGS (object);
   self->system = g_settings_new ("org.gnome.desktop.interface");
 
-
-  g_settings_bind  (settings, "use-system-font",
-                    self,     "use-system-font",
-                    G_SETTINGS_BIND_DEFAULT);
-
-  g_settings_bind  (settings, "font",
-                    self,     "font",
-                    G_SETTINGS_BIND_DEFAULT);
-
-  g_settings_bind  (settings, "color",
-                    self,     "color",
-                    G_SETTINGS_BIND_DEFAULT);
-
-  g_settings_bind  (settings,  "default-location",
-                    self,      "default-location",
-                    G_SETTINGS_BIND_DEFAULT);
+  self->use_system_font = g_settings_get_boolean (settings, "use-system-font");
+  self->font = g_settings_get_string (settings, "font");
+  self->color = g_settings_get_string (settings, "color");
+  self->primary = g_settings_get_string (settings, "default-location");
 }
 
 
-- 
cgit v0.12


From 0c7061de9e2987de351c30dae28a5b749cd525fc Mon Sep 17 00:00:00 2001
From: Isaque Galdino <igaldino@gmail.com>
Date: Mon, 16 Apr 2018 17:51:02 -0300
Subject: item: Fix memory leak

---
 src/libbiji/biji-item.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/libbiji/biji-item.c b/src/libbiji/biji-item.c
index a96bfb2..ae8aa7e 100644
--- a/src/libbiji/biji-item.c
+++ b/src/libbiji/biji-item.c
@@ -151,7 +151,8 @@ biji_item_class_init (BijiItemClass *klass)
 static void
 biji_item_finalize (GObject *object)
 {
-  g_return_if_fail (BIJI_IS_ITEM (object));
+  BijiItemPrivate *priv = biji_item_get_instance_private (BIJI_ITEM (object));
+  g_clear_object (&priv->manager);
 
   G_OBJECT_CLASS (biji_item_parent_class)->finalize (object);
 }
-- 
cgit v0.12


From 3853bc82c39e5331bc963f3664a679c23f6e3708 Mon Sep 17 00:00:00 2001
From: Isaque Galdino <igaldino@gmail.com>
Date: Mon, 16 Apr 2018 17:51:23 -0300
Subject: note-id: Fix memory leak

---
 src/libbiji/biji-note-id.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libbiji/biji-note-id.c b/src/libbiji/biji-note-id.c
index b056af6..f495c50 100644
--- a/src/libbiji/biji-note-id.c
+++ b/src/libbiji/biji-note-id.c
@@ -35,7 +35,7 @@ struct _BijiNoteID
   GObject       parent_instance;
   /* InfoSet */
 
-  const gchar  *path;
+  gchar        *path;
   gchar        *title;
   gchar        *content;
   gint64        mtime;
@@ -63,7 +63,9 @@ biji_note_id_finalize (GObject *object)
 {
   BijiNoteID *self = BIJI_NOTE_ID (object);
 
+  g_free (self->path);
   g_free (self->title);
+  g_free (self->content);
 
   G_OBJECT_CLASS (biji_note_id_parent_class)->finalize (object);
 }
@@ -99,7 +101,7 @@ biji_note_id_set_property  (GObject      *object,
       self->mtime = g_value_get_int64 (value);
       break;
     case PROP_CONTENT:
-      self->content = g_strdup (g_value_get_string (value));
+      biji_note_id_set_content (self, g_value_get_string (value));
       g_object_notify_by_pspec (object, properties[PROP_CONTENT]);
       break;
     default:
-- 
cgit v0.12


From 5a7f29ed5192ac02759bd8119f027ee14fbab65f Mon Sep 17 00:00:00 2001
From: Isaque Galdino <igaldino@gmail.com>
Date: Mon, 16 Apr 2018 17:51:48 -0300
Subject: provider: Fix memory leak

---
 src/libbiji/provider/biji-provider.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/libbiji/provider/biji-provider.c b/src/libbiji/provider/biji-provider.c
index d351040..0b51e89 100644
--- a/src/libbiji/provider/biji-provider.c
+++ b/src/libbiji/provider/biji-provider.c
@@ -111,11 +111,8 @@ biji_provider_load_archives        (BijiProvider *provider)
 static void
 biji_provider_finalize (GObject *object)
 {
-  //BijiProvider *self;
-
-  //g_return_if_fail (BIJI_IS_PROVIDER (object));
-
-  //self = BIJI_PROVIDER (object);
+  BijiProviderPrivate *priv = biji_provider_get_instance_private (BIJI_PROVIDER (object));
+  g_clear_object (&priv->manager);
 
   G_OBJECT_CLASS (biji_provider_parent_class)->finalize (object);
 }
-- 
cgit v0.12

openSUSE Build Service is sponsored by