gtk: clean up properly in GtkFileChooserEntry's dispose() to fix crashes

Don't just unref the completion_store, call discard_completion_store()
instead which also unsets it as the GtkEntryCompletion's model.  Fixes
bug 681845 and probably some others, because the situation in this bug
is completely common.
This commit is contained in:
Michael Natterer
2012-11-05 20:15:17 +01:00
parent c5421263e4
commit 376fc4d712

View File

@ -287,6 +287,17 @@ discard_loading_and_current_folder_file (GtkFileChooserEntry *chooser_entry)
} }
} }
static void
discard_completion_store (GtkFileChooserEntry *chooser_entry)
{
if (!chooser_entry->completion_store)
return;
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);
g_object_unref (chooser_entry->completion_store);
chooser_entry->completion_store = NULL;
}
static void static void
gtk_file_chooser_entry_dispose (GObject *object) gtk_file_chooser_entry_dispose (GObject *object)
{ {
@ -302,11 +313,7 @@ gtk_file_chooser_entry_dispose (GObject *object)
chooser_entry->start_autocompletion_idle_id = 0; chooser_entry->start_autocompletion_idle_id = 0;
} }
if (chooser_entry->completion_store) discard_completion_store (chooser_entry);
{
g_object_unref (chooser_entry->completion_store);
chooser_entry->completion_store = NULL;
}
if (chooser_entry->file_system) if (chooser_entry->file_system)
{ {
@ -1297,17 +1304,6 @@ gtk_file_chooser_entry_activate (GtkEntry *entry)
GTK_ENTRY_CLASS (_gtk_file_chooser_entry_parent_class)->activate (entry); GTK_ENTRY_CLASS (_gtk_file_chooser_entry_parent_class)->activate (entry);
} }
static void
discard_completion_store (GtkFileChooserEntry *chooser_entry)
{
if (!chooser_entry->completion_store)
return;
gtk_entry_completion_set_model (gtk_entry_get_completion (GTK_ENTRY (chooser_entry)), NULL);
g_object_unref (chooser_entry->completion_store);
chooser_entry->completion_store = NULL;
}
/* Fills the completion store from the contents of the current folder */ /* Fills the completion store from the contents of the current folder */
static void static void
populate_completion_store (GtkFileChooserEntry *chooser_entry) populate_completion_store (GtkFileChooserEntry *chooser_entry)