[gtk+] Don't keep the filesystem model alive while querying files



commit ba9f53397ff0b86ad56166c7fc91b4d499f7aefc
Author: Benjamin Otte <otte gnome org>
Date:   Mon Nov 2 19:49:11 2009 +0100

    Don't keep the filesystem model alive while querying files
    
    This allows disposing of the filesystemmodel while the file enumeration
    is still happening.
    As the filechooser does not disconnect its signals because it assumes it
    is the only owner of the model, this also prevents a SEGV when emitting
    the "load-finished" signal in that case.

 gtk/gtkfilesystemmodel.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 095969b..c73ebb8 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -1113,24 +1113,25 @@ gtk_file_system_model_got_files (GObject *object, GAsyncResult *res, gpointer da
     }
   else
     {
-      g_file_enumerator_close_async (enumerator, 
-                                     IO_PRIORITY,
-                                     model->cancellable,
-                                     gtk_file_system_model_closed_enumerator,
-                                     model);
-      if (model->dir_thaw_source != 0)
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         {
-          g_source_remove (model->dir_thaw_source);
-          model->dir_thaw_source = 0;
-          _gtk_file_system_model_thaw_updates (model);
-        }
+          g_file_enumerator_close_async (enumerator,
+                                         IO_PRIORITY,
+                                         model->cancellable,
+                                         gtk_file_system_model_closed_enumerator,
+                                         NULL);
+          if (model->dir_thaw_source != 0)
+            {
+              g_source_remove (model->dir_thaw_source);
+              model->dir_thaw_source = 0;
+              _gtk_file_system_model_thaw_updates (model);
+            }
 
-      g_signal_emit (model, file_system_model_signals[FINISHED_LOADING], 0, error);
+          g_signal_emit (model, file_system_model_signals[FINISHED_LOADING], 0, error);
+        }
 
       if (error)
         g_error_free (error);
-
-      g_object_unref (model);
     }
 
   gdk_threads_leave ();
@@ -1270,7 +1271,6 @@ gtk_file_system_model_set_directory (GtkFileSystemModel *model,
   model->dir = g_object_ref (dir);
   model->attributes = g_strdup (attributes);
 
-  g_object_ref (model);
   g_file_enumerate_children_async (model->dir,
                                    attributes,
                                    G_FILE_QUERY_INFO_NONE,



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