[Xfce4-commits] <ristretto:master> Add a reference to the file object when calling the 'add_recent_files' sourcefunc. That function will own the reference and remove it when done.

Stephan Arts noreply at xfce.org
Sat Sep 3 00:22:01 CEST 2011


Updating branch refs/heads/master
         to cb8b7cf2c8aee871e04029048b4e09909dde3dad (commit)
       from 857e80a658736edf5ac8a0d15f83390db8adc57c (commit)

commit cb8b7cf2c8aee871e04029048b4e09909dde3dad
Author: Stephan Arts <stephan at xfce.org>
Date:   Sat Sep 3 00:21:12 2011 +0200

    Add a reference to the file object when calling the 'add_recent_files'
    sourcefunc. That function will own the reference and remove it when
    done.

 src/main_window.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/main_window.c b/src/main_window.c
index f8e32d5..bcf0d7a 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -2052,6 +2052,10 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
                 }
                 else
                 {
+                    /* Add a reference to the file, it is owned by the
+                     * sourcefunc and will be unref-ed by it.
+                     */
+                    g_object_ref (file);
                     g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) rstto_main_window_add_file_to_recent_files, file, NULL);
                 }
 
@@ -2073,6 +2077,10 @@ cb_rstto_main_window_open_image (GtkWidget *widget, RsttoMainWindow *window)
             }
             else
             {
+                /* Add a reference to the file, it is owned by the
+                 * sourcefunc and will be unref-ed by it.
+                 */
+                g_object_ref (files->data);
                 g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) rstto_main_window_add_file_to_recent_files, files->data, NULL);
             }
         }
@@ -2157,6 +2165,10 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window)
             rstto_image_list_iter_set_position (window->priv->iter, 0);
         }
 
+        /* Add a reference to the file, it is owned by the
+         * sourcefunc and will be unref-ed by it.
+         */
+        g_object_ref (file);
         g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) rstto_main_window_add_file_to_recent_files,
         file, NULL);
 
@@ -2308,6 +2320,7 @@ cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window)
     rstto_image_list_remove_file (window->priv->props.image_list, file);
 
     rstto_main_window_update_buttons (window);
+    rstto_main_window_image_list_iter_changed (window);
 }
 
 /**
@@ -2324,6 +2337,7 @@ cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window)
     rstto_main_window_image_list_iter_changed (window);
 
     rstto_main_window_update_buttons (window);
+    rstto_main_window_image_list_iter_changed (window);
 }
 
 
@@ -2516,6 +2530,7 @@ rstto_main_window_add_file_to_recent_files (GFile *file)
 
     g_slice_free (GtkRecentData, recent_data);
 
+    g_object_unref (file);
     return FALSE;
 }
 


More information about the Xfce4-commits mailing list