Commit d69788f0 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Don't leak all search results

svn path=/trunk/; revision=21317
parent ef5855fe
2008-09-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (search_selected_foreach_get_file_cb):
Ref the files, to make gtk_file_chooser_get_files() behave as
documented.
* gtk/gtkfilechooserdefault.c (search_clear_model): Don't leak
the content of the search model.
* gtk/gtkfilechooserdefault.c (search_hit_get_info_cb): Don't leak
the content here, either.
2008-09-07 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (search_add_hit): Don't unref the
......
......@@ -432,6 +432,8 @@ static void location_switch_to_path_bar (GtkFileChooserDefault *impl);
static void search_stop_searching (GtkFileChooserDefault *impl,
gboolean remove_query);
static void search_clear_model_row (GtkTreeModel *model,
GtkTreeIter *iter);
static void search_clear_model (GtkFileChooserDefault *impl,
gboolean remove_from_treeview);
static gboolean search_should_respond (GtkFileChooserDefault *impl);
......@@ -1936,7 +1938,7 @@ shortcuts_append_bookmarks (GtkFileChooserDefault *impl,
{
int start_row;
int num_inserted;
const gchar *label;
gchar *label;
profile_start ("start", NULL);
......@@ -8502,7 +8504,7 @@ search_selected_foreach_get_file_cb (GtkTreeModel *model,
list = data;
gtk_tree_model_get (model, iter, SEARCH_MODEL_COL_FILE, &file, -1);
*list = g_slist_prepend (*list, file);
*list = g_slist_prepend (*list, g_object_ref (file));
}
/* Constructs a list of the selected paths in search mode */
......@@ -8585,6 +8587,7 @@ search_hit_get_info_cb (GCancellable *cancellable,
if (!info)
{
search_clear_model_row (request->impl->search_model, &iter);
gtk_list_store_remove (request->impl->search_model, &iter);
goto out;
}
......@@ -8744,6 +8747,38 @@ search_engine_error_cb (GtkSearchEngine *engine,
set_busy_cursor (impl, FALSE);
}
static void
search_clear_model_row (GtkTreeModel *model,
GtkTreeIter *iter)
{
GFile *file;
gchar *display_name;
gchar *collation_key;
struct stat *statbuf;
GCancellable *cancellable;
gchar *mime_type;
gtk_tree_model_get (model, iter,
SEARCH_MODEL_COL_FILE, &file,
SEARCH_MODEL_COL_DISPLAY_NAME, &display_name,
SEARCH_MODEL_COL_COLLATION_KEY, &collation_key,
SEARCH_MODEL_COL_STAT, &statbuf,
SEARCH_MODEL_COL_CANCELLABLE, &cancellable,
SEARCH_MODEL_COL_MIME_TYPE, &mime_type,
-1);
if (file)
g_object_unref (file);
g_free (display_name);
g_free (collation_key);
g_free (statbuf);
g_free (mime_type);
if (cancellable)
g_cancellable_cancel (cancellable);
}
/* Frees the data in the search_model */
static void
search_clear_model (GtkFileChooserDefault *impl,
......@@ -8760,14 +8795,7 @@ search_clear_model (GtkFileChooserDefault *impl,
if (gtk_tree_model_get_iter_first (model, &iter))
do
{
GCancellable *cancellable;
gtk_tree_model_get (model, &iter,
SEARCH_MODEL_COL_CANCELLABLE, &cancellable,
-1);
if (cancellable)
g_cancellable_cancel (cancellable);
search_clear_model_row (model, &iter);
}
while (gtk_tree_model_iter_next (model, &iter));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment