[eog: 1/2] EogWindow: Fix memory leak when using flag EOG_STARTUP_SINGLE_WINDOW




commit 2676ee663d2e82b3681ab309e2c532e4f3f646ca
Author: Krifa75 <yahiaoui fakhri gmail com>
Date:   Tue Nov 3 18:04:51 2020 +0000

    EogWindow: Fix memory leak when using flag EOG_STARTUP_SINGLE_WINDOW
    
    Free the file_list if we reopen with the flag EOG_STARTUP_SINGLE_WINDOW
    to avoid a memory leak as mentioned in !81.

 src/eog-window.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/eog-window.c b/src/eog-window.c
index a8b720de..131d0b37 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -4472,6 +4472,7 @@ eog_window_init (EogWindow *window)
        priv->view_settings = g_settings_new (EOG_CONF_VIEW);
        priv->lockdown_settings = g_settings_new (EOG_CONF_DESKTOP_LOCKDOWN_SCHEMA);
 
+       window->priv->file_list = NULL;
        window->priv->store = NULL;
        window->priv->image = NULL;
 
@@ -5247,6 +5248,14 @@ eog_window_open_file_list (EogWindow *window, GSList *file_list)
 
        window->priv->status = EOG_WINDOW_STATUS_INIT;
 
+       /* Free the list to avoid memory leak
+        * when using flag EOG_STARTUP_SINGLE_WINDOW
+        */
+       if (window->priv->file_list != NULL) {
+               g_slist_foreach (window->priv->file_list, (GFunc) g_object_unref, NULL);
+               g_slist_free (window->priv->file_list);
+       }
+
        g_slist_foreach (file_list, (GFunc) g_object_ref, NULL);
        window->priv->file_list = file_list;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]