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
=== modified file 'src/View/AbstractDirectoryView.vala'
--- src/View/AbstractDirectoryView.vala 2015-06-06 08:41:29 +0000
+++ src/View/AbstractDirectoryView.vala 2015-06-20 09:24:39 +0000
@@ -194,7 +194,7 @@
194 private Gdk.Cursor selectable_cursor;194 private Gdk.Cursor selectable_cursor;
195195
196 private GLib.List<GLib.AppInfo> open_with_apps;196 private GLib.List<GLib.AppInfo> open_with_apps;
197 protected GLib.List<GOF.Directory.Async>? loaded_subdirectories = null;197 protected GLib.List<GOF.Directory.Async> loaded_subdirectories = null;
198198
199 /* Selected files are originally obtained with199 /* Selected files are originally obtained with
200 gtk_tree_model_get(): this function increases the reference200 gtk_tree_model_get(): this function increases the reference
@@ -277,9 +277,6 @@
277277
278 ~AbstractDirectoryView () {278 ~AbstractDirectoryView () {
279 debug ("ADV destruct");279 debug ("ADV destruct");
280 loaded_subdirectories.@foreach ((dir) => {
281 remove_subdirectory (dir);
282 });
283 }280 }
284281
285 protected virtual void set_up_name_renderer () {282 protected virtual void set_up_name_renderer () {
@@ -590,17 +587,11 @@
590 }587 }
591588
592 public void change_directory (GOF.Directory.Async old_dir, GOF.Directory.Async new_dir) {589 public void change_directory (GOF.Directory.Async old_dir, GOF.Directory.Async new_dir) {
593 cancel_thumbnailing ();590 cancel ();
594 freeze_tree ();591 freeze_tree ();
595 old_dir.cancel ();592 old_dir.cancel ();
596 disconnect_directory_handlers (old_dir);593 disconnect_directory_handlers (old_dir);
597 block_model ();594 block_model ();
598
599 loaded_subdirectories.@foreach ((dir) => {
600 remove_subdirectory (dir);
601 });
602
603 loaded_subdirectories = null;
604 model.clear ();595 model.clear ();
605 unblock_model ();596 unblock_model ();
606 if (new_dir.can_load)597 if (new_dir.can_load)
@@ -3022,7 +3013,6 @@
3022 slot.directory.cancel ();3013 slot.directory.cancel ();
3023 cancel_drag_timer ();3014 cancel_drag_timer ();
3024 cancel_timeout (ref drag_scroll_timer_id);3015 cancel_timeout (ref drag_scroll_timer_id);
3025
3026 loaded_subdirectories.@foreach ((dir) => {3016 loaded_subdirectories.@foreach ((dir) => {
3027 remove_subdirectory (dir);3017 remove_subdirectory (dir);
3028 });3018 });
30293019
=== modified file 'src/View/ListView.vala'
--- src/View/ListView.vala 2015-05-23 12:02:29 +0000
+++ src/View/ListView.vala 2015-06-20 09:24:39 +0000
@@ -30,6 +30,7 @@
30 };30 };
3131
32 private uint unload_file_timeout_id = 0;32 private uint unload_file_timeout_id = 0;
33 private GLib.List<GOF.File> subdirectories_to_unload = null;
3334
34 public ListView (Marlin.View.Slot _slot) {35 public ListView (Marlin.View.Slot _slot) {
35 base (_slot);36 base (_slot);
@@ -82,8 +83,9 @@
82 set_path_expanded (path, false);83 set_path_expanded (path, false);
8384
84 if (model.get_directory_file (path, out dir, out file)) {85 if (model.get_directory_file (path, out dir, out file)) {
85 schedule_model_unload_directory (file, dir);
86 remove_subdirectory (dir);86 remove_subdirectory (dir);
87 subdirectories_to_unload.append (file);
88 schedule_model_unload_directories ();
87 } else89 } else
88 critical ("failed to get directory/file");90 critical ("failed to get directory/file");
89 }91 }
@@ -95,8 +97,14 @@
95 file.set_expanded (expanded);97 file.set_expanded (expanded);
96 }98 }
9799
98 private void schedule_model_unload_directory (GOF.File file, GOF.Directory.Async directory) {100 private void schedule_model_unload_directories () {
99 unload_file_timeout_id = GLib.Timeout.add_seconds (COLLAPSE_TO_UNLOAD_DELAY, () => {101 cancel_file_timeout ();
102 unload_file_timeout_id = GLib.Timeout.add_seconds (COLLAPSE_TO_UNLOAD_DELAY,
103 unload_directories);
104 }
105
106 private bool unload_directories () {
107 foreach (var file in subdirectories_to_unload) {
100 Gtk.TreeIter iter;108 Gtk.TreeIter iter;
101 Gtk.TreePath path;109 Gtk.TreePath path;
102110
@@ -105,11 +113,15 @@
105 if (path != null && !((Gtk.TreeView)tree).is_row_expanded (path))113 if (path != null && !((Gtk.TreeView)tree).is_row_expanded (path))
106 model.unload_subdirectory (iter);114 model.unload_subdirectory (iter);
107 } else115 } else
108 critical ("Failed to get iter");116 warning ("Subdirectory to unload not found in model");
117 }
109118
110 unload_file_timeout_id = 0;119 subdirectories_to_unload.@foreach ((file) => {
111 return false;120 subdirectories_to_unload.remove (file);
112 });121 });
122
123 unload_file_timeout_id = 0;
124 return false;
113 }125 }
114126
115 private void cancel_file_timeout () {127 private void cancel_file_timeout () {

Subscribers

People subscribed via source and target branches

to all changes: