1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
From 834c4e7fe39f7053efdb126f9e1835e6b8e529f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Thu, 26 Jul 2018 02:55:19 +0000
Subject: [PATCH 1/3] 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)
---
src/nautilus-files-view.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 8784f63f8..36d791f80 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -3556,7 +3556,6 @@ done_loading (NautilusFilesView *view,
gboolean all_files_seen)
{
NautilusFilesViewPrivate *priv;
- GList *pending_selection;
GList *selection;
gboolean do_reveal = FALSE;
@@ -3577,21 +3576,23 @@ 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;
+ GList *pending_selection;
+ pending_selection = g_steal_pointer (&priv->pending_selection);
nautilus_files_view_call_set_selection (view, pending_selection);
do_reveal = TRUE;
+
+ nautilus_file_list_free (pending_selection);
}
if (selection)
@@ -3599,10 +3600,7 @@ done_loading (NautilusFilesView *view,
g_list_free_full (selection, g_object_unref);
}
- 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)
{
--
2.17.0
|