Merge lp:~jeremywootten/pantheon-files/fix-1465121-critical-warning-after-row-collapse into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1855
Merged at revision: 1874
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1465121-critical-warning-after-row-collapse
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 108 lines (+20/-18)
2 files modified
src/View/AbstractDirectoryView.vala (+2/-12)
src/View/ListView.vala (+18/-6)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1465121-critical-warning-after-row-collapse
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+262516@code.launchpad.net

Commit message

Fix critical warnings when unloading of subdirectories (lp:1465121)

Description of the change

This branch prevents some critical warnings appearing in the terminal when collapsing rows in List View.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/View/AbstractDirectoryView.vala'
2--- src/View/AbstractDirectoryView.vala 2015-06-06 08:41:29 +0000
3+++ src/View/AbstractDirectoryView.vala 2015-06-20 09:24:39 +0000
4@@ -194,7 +194,7 @@
5 private Gdk.Cursor selectable_cursor;
6
7 private GLib.List<GLib.AppInfo> open_with_apps;
8- protected GLib.List<GOF.Directory.Async>? loaded_subdirectories = null;
9+ protected GLib.List<GOF.Directory.Async> loaded_subdirectories = null;
10
11 /* Selected files are originally obtained with
12 gtk_tree_model_get(): this function increases the reference
13@@ -277,9 +277,6 @@
14
15 ~AbstractDirectoryView () {
16 debug ("ADV destruct");
17- loaded_subdirectories.@foreach ((dir) => {
18- remove_subdirectory (dir);
19- });
20 }
21
22 protected virtual void set_up_name_renderer () {
23@@ -590,17 +587,11 @@
24 }
25
26 public void change_directory (GOF.Directory.Async old_dir, GOF.Directory.Async new_dir) {
27- cancel_thumbnailing ();
28+ cancel ();
29 freeze_tree ();
30 old_dir.cancel ();
31 disconnect_directory_handlers (old_dir);
32 block_model ();
33-
34- loaded_subdirectories.@foreach ((dir) => {
35- remove_subdirectory (dir);
36- });
37-
38- loaded_subdirectories = null;
39 model.clear ();
40 unblock_model ();
41 if (new_dir.can_load)
42@@ -3022,7 +3013,6 @@
43 slot.directory.cancel ();
44 cancel_drag_timer ();
45 cancel_timeout (ref drag_scroll_timer_id);
46-
47 loaded_subdirectories.@foreach ((dir) => {
48 remove_subdirectory (dir);
49 });
50
51=== modified file 'src/View/ListView.vala'
52--- src/View/ListView.vala 2015-05-23 12:02:29 +0000
53+++ src/View/ListView.vala 2015-06-20 09:24:39 +0000
54@@ -30,6 +30,7 @@
55 };
56
57 private uint unload_file_timeout_id = 0;
58+ private GLib.List<GOF.File> subdirectories_to_unload = null;
59
60 public ListView (Marlin.View.Slot _slot) {
61 base (_slot);
62@@ -82,8 +83,9 @@
63 set_path_expanded (path, false);
64
65 if (model.get_directory_file (path, out dir, out file)) {
66- schedule_model_unload_directory (file, dir);
67 remove_subdirectory (dir);
68+ subdirectories_to_unload.append (file);
69+ schedule_model_unload_directories ();
70 } else
71 critical ("failed to get directory/file");
72 }
73@@ -95,8 +97,14 @@
74 file.set_expanded (expanded);
75 }
76
77- private void schedule_model_unload_directory (GOF.File file, GOF.Directory.Async directory) {
78- unload_file_timeout_id = GLib.Timeout.add_seconds (COLLAPSE_TO_UNLOAD_DELAY, () => {
79+ private void schedule_model_unload_directories () {
80+ cancel_file_timeout ();
81+ unload_file_timeout_id = GLib.Timeout.add_seconds (COLLAPSE_TO_UNLOAD_DELAY,
82+ unload_directories);
83+ }
84+
85+ private bool unload_directories () {
86+ foreach (var file in subdirectories_to_unload) {
87 Gtk.TreeIter iter;
88 Gtk.TreePath path;
89
90@@ -105,11 +113,15 @@
91 if (path != null && !((Gtk.TreeView)tree).is_row_expanded (path))
92 model.unload_subdirectory (iter);
93 } else
94- critical ("Failed to get iter");
95+ warning ("Subdirectory to unload not found in model");
96+ }
97
98- unload_file_timeout_id = 0;
99- return false;
100+ subdirectories_to_unload.@foreach ((file) => {
101+ subdirectories_to_unload.remove (file);
102 });
103+
104+ unload_file_timeout_id = 0;
105+ return false;
106 }
107
108 private void cancel_file_timeout () {

Subscribers

People subscribed via source and target branches

to all changes: