summaryrefslogtreecommitdiff
path: root/gtk/gtkfilesystemmodel.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-11-02 19:49:11 +0100
committerBenjamin Otte <otte@gnome.org>2009-11-02 20:11:09 +0100
commitba9f53397ff0b86ad56166c7fc91b4d499f7aefc (patch)
tree8467d984b11cbc627b2e935033b2d93f16f2748d /gtk/gtkfilesystemmodel.c
parent8632d8763d1613d2b938f47b155b68caf2d2cc57 (diff)
downloadgtk+-ba9f53397ff0b86ad56166c7fc91b4d499f7aefc.tar.gz
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.
Diffstat (limited to 'gtk/gtkfilesystemmodel.c')
-rw-r--r--gtk/gtkfilesystemmodel.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 095969bdc6..c73ebb8fa0 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,