filebrowser: Don't leak GFiles

e2f792359a
This commit is contained in:
JosephMcc
2017-02-13 15:57:16 -08:00
parent fe9e6ac91c
commit fa31c65c2f
5 changed files with 116 additions and 67 deletions

View File

@@ -165,7 +165,6 @@ row_expanded (GtkTreeView *tree_view,
GtkTreePath *path)
{
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view);
GFile *location;
if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_expanded)
{
@@ -179,9 +178,16 @@ row_expanded (GtkTreeView *tree_view,
if (view->priv->restore_expand_state)
{
GFile *location;
gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1);
add_expand_state (view, location);
if (location)
{
g_object_unref (location);
}
}
_xed_file_browser_store_iter_expanded (XED_FILE_BROWSER_STORE (view->priv->model), iter);
@@ -193,7 +199,6 @@ row_collapsed (GtkTreeView *tree_view,
GtkTreePath *path)
{
XedFileBrowserView *view = XED_FILE_BROWSER_VIEW (tree_view);
GFile *location;
if (GTK_TREE_VIEW_CLASS (xed_file_browser_view_parent_class)->row_collapsed)
{
@@ -207,9 +212,16 @@ row_collapsed (GtkTreeView *tree_view,
if (view->priv->restore_expand_state)
{
GFile *location;
gtk_tree_model_get (view->priv->model, iter, XED_FILE_BROWSER_STORE_COLUMN_LOCATION, &location, -1);
remove_expand_state (view, location);
if (location)
{
g_object_unref (location);
}
}
_xed_file_browser_store_iter_collapsed (XED_FILE_BROWSER_STORE (view->priv->model), iter);
@@ -747,7 +759,6 @@ fill_expand_state (XedFileBrowserView *view,
{
GtkTreePath * path;
GtkTreeIter child;
GFile *location;
if (!gtk_tree_model_iter_has_child (view->priv->model, iter))
{
@@ -758,6 +769,8 @@ fill_expand_state (XedFileBrowserView *view,
if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path))
{
GFile *location;
gtk_tree_model_get (view->priv->model,
iter,
XED_FILE_BROWSER_STORE_COLUMN_LOCATION,
@@ -765,6 +778,11 @@ fill_expand_state (XedFileBrowserView *view,
-1);
add_expand_state (view, location);
if (location)
{
g_object_unref (location);
}
}
if (gtk_tree_model_iter_children (view->priv->model, &child, iter))
@@ -1269,7 +1287,6 @@ restore_expand_state (XedFileBrowserView *view,
GtkTreeIter *iter)
{
GFile *location;
GtkTreePath *path;
gtk_tree_model_get (GTK_TREE_MODEL (model),
iter,
@@ -1277,19 +1294,20 @@ restore_expand_state (XedFileBrowserView *view,
&location,
-1);
if (!location)
if (location)
{
return;
GtkTreePath *path;
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
if (g_hash_table_lookup (view->priv->expand_state, location))
{
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
}
gtk_tree_path_free (path);
g_object_unref (location);
}
path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
if (g_hash_table_lookup (view->priv->expand_state, location))
{
gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE);
}
gtk_tree_path_free (path);
}
static void