summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2018-07-26 02:55:19 +0000
committerMarco Trevisan <mail@3v1n0.net>2018-07-26 11:06:26 +0000
commit64580eaa099d4036d0d455ac81e681d0786bca31 (patch)
tree7b0de73c20731a924b65bcb2b9de03a422ed5628
parentff776c252121710a73602d8affd3ba48af31dee6 (diff)
downloadnautilus-64580eaa099d4036d0d455ac81e681d0786bca31.tar.gz
file-view: Always unset pending_selection after freeing it
When a file view was loaded with a pending selection, and not all the files were seen yet, the private pending_selection list was properly free'd, but the pointer was not cleared, causing a crash when `nautilus_files_view_set_selection` was called again, as it was trying to deeply copy a list pointed by this invalid reference. So, removing the unneeded `pending_selection` temporary pointer from the main function scope, as it only confuses, while use it (with an autolist) when we need to pass the previous `priv->pending_selection` (stealing its ownership) to set_selection again. Eventually use a g_clear_pointer to free the list and nullify its priv reference Fixes #295 (cherry picked from commit ae3382a281b018337a8032ef13663ec2d9c7fd6c)
-rw-r--r--src/nautilus-files-view.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 0c7380ae9..8aff33e25 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3520,7 +3520,6 @@ done_loading (NautilusFilesView *view,
gboolean all_files_seen)
{
NautilusFilesViewPrivate *priv;
- GList *pending_selection;
g_autolist (NautilusFile) selection = NULL;
gboolean do_reveal = FALSE;
@@ -3541,27 +3540,24 @@ done_loading (NautilusFilesView *view,
nautilus_files_view_update_toolbar_menus (view);
reset_update_interval (view);
- pending_selection = priv->pending_selection;
selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
if (nautilus_view_is_searching (NAUTILUS_VIEW (view)) &&
- all_files_seen && !selection && !pending_selection)
+ all_files_seen && selection == NULL && priv->pending_selection == NULL)
{
nautilus_files_view_select_first (view);
do_reveal = TRUE;
}
- else if (pending_selection != NULL && all_files_seen)
+ else if (priv->pending_selection != NULL && all_files_seen)
{
- priv->pending_selection = NULL;
+ g_autolist (NautilusFile) pending_selection = NULL;
+ pending_selection = g_steal_pointer (&priv->pending_selection);
nautilus_files_view_call_set_selection (view, pending_selection);
do_reveal = TRUE;
}
- if (pending_selection)
- {
- g_list_free_full (pending_selection, g_object_unref);
- }
+ g_clear_pointer (&priv->pending_selection, nautilus_file_list_free);
if (do_reveal)
{