Merge lp:~jeremywootten/pantheon-files/fix-1464978-crash-after-reloading-duplicate-tab into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1856
Merged at revision: 1872
Proposed branch: lp:~jeremywootten/pantheon-files/fix-1464978-crash-after-reloading-duplicate-tab
Merge into: lp:~elementary-apps/pantheon-files/trunk
Prerequisite: lp:~jeremywootten/pantheon-files/fix-potential-infinite-loop-in-select-glib-files
Diff against target: 364 lines (+42/-82)
8 files modified
libcore/AbstractSlot.vala (+1/-1)
libcore/gof-directory-async.vala (+2/-0)
src/Application.vala (+0/-13)
src/View/AbstractDirectoryView.vala (+10/-28)
src/View/Miller.vala (+2/-2)
src/View/Slot.vala (+10/-6)
src/View/ViewContainer.vala (+7/-22)
src/View/Window.vala (+10/-10)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/fix-1464978-crash-after-reloading-duplicate-tab
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+262536@code.launchpad.net

Commit message

Fix reloading when view open in multiple tabs and windows (lp:1464978)

Description of the change

This branch fixes the reloading of views that are displayed in multiple tabs and windows, ensuring the models of all views linked to the reloaded directory are refreshed.

It is essential that the branch lp:~jeremywootten/pantheon-files/fix-potential-infinite-loop-in-select-glib-files is merged first otherwise an infinite loop can be created in an Idle when going back in history.

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Conflicts with trunk

1856. By Jeremy Wootten

Merge trunk to rev 1871 and resolve conflict

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Conflict with trunk now resolved.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libcore/AbstractSlot.vala'
2--- libcore/AbstractSlot.vala 2015-05-03 06:44:42 +0000
3+++ libcore/AbstractSlot.vala 2015-06-30 14:19:06 +0000
4@@ -57,7 +57,7 @@
5 public abstract unowned GLib.List<unowned GOF.File>? get_selected_files ();
6 public abstract void set_active_state (bool set_active);
7 public abstract unowned AbstractSlot? get_current_slot ();
8- public abstract void reload ();
9+ public abstract void reload (bool non_local_only = false);
10 public abstract void grab_focus ();
11 public abstract void user_path_change_request (GLib.File loc, bool allow_mode_change = true);
12 public abstract void select_first_for_empty_selection ();
13
14=== modified file 'libcore/gof-directory-async.vala'
15--- libcore/gof-directory-async.vala 2015-05-25 09:06:09 +0000
16+++ libcore/gof-directory-async.vala 2015-06-30 14:19:06 +0000
17@@ -284,6 +284,8 @@
18 }
19
20 public void clear_directory_info () {
21+ cancel ();
22+
23 if (idle_consume_changes_id != 0) {
24 Source.remove ((uint) idle_consume_changes_id);
25 idle_consume_changes_id = 0;
26
27=== modified file 'src/Application.vala'
28--- src/Application.vala 2015-05-03 06:44:42 +0000
29+++ src/Application.vala 2015-06-30 14:19:06 +0000
30@@ -235,19 +235,6 @@
31 });
32 }
33
34- public void tab_reloaded (Marlin.View.Window source, GLib.File file) {
35- unowned List<Gtk.Window> window_list = this.get_windows ();
36- window_list.@foreach ((window) => {
37- var win = (Marlin.View.Window)window;
38-
39- if ((source.window_number != win.window_number) &&
40- file.equal (win.current_tab.get_current_slot ().location))
41-
42- win.current_tab.reload (false);
43-
44- });
45- }
46-
47 private void mount_removed_callback (VolumeMonitor monitor, Mount mount) {
48 /* Notify each window */
49 foreach (var window in this.get_windows ()) {
50
51=== modified file 'src/View/AbstractDirectoryView.vala'
52--- src/View/AbstractDirectoryView.vala 2015-06-24 07:49:55 +0000
53+++ src/View/AbstractDirectoryView.vala 2015-06-30 14:19:06 +0000
54@@ -587,17 +587,10 @@
55 }
56
57 public void change_directory (GOF.Directory.Async old_dir, GOF.Directory.Async new_dir) {
58- cancel_thumbnailing ();
59+ cancel ();
60 freeze_tree ();
61- old_dir.cancel ();
62 disconnect_directory_handlers (old_dir);
63 block_model ();
64-
65- loaded_subdirectories.@foreach ((dir) => {
66- remove_subdirectory (dir);
67- });
68-
69- loaded_subdirectories = null;
70 model.clear ();
71 unblock_model ();
72 if (new_dir.can_load)
73@@ -605,7 +598,6 @@
74 }
75
76 public void reload () {
77- slot.directory.clear_directory_info ();
78 change_directory (slot.directory, slot.directory);
79 }
80
81@@ -833,15 +825,12 @@
82
83 var file_to_rename = GOF.File.@get (new_file);
84 bool local = view.slot.directory.is_local;
85- if (!local)
86- view.slot.directory.need_reload ();
87+ view.slot.reload (true); /* non-local only */
88
89 /* Allow time for the file to appear in the tree model before renaming
90 * Wait longer for remote locations to allow for reload.
91 */
92-
93 /**TODO** Remove need for hard coded delay*/
94-
95 int delay = local ? 250 : 500;
96 GLib.Timeout.add (delay, () => {
97 view.rename_file (file_to_rename);
98@@ -858,9 +847,7 @@
99 return;
100
101 view.can_trash_or_delete = true;
102-
103- if (!view.slot.directory.is_local)
104- view.slot.directory.need_reload ();
105+ view.slot.reload (true); /* non-local only */
106 }
107
108 private void trash_or_delete_selected_files (bool delete_immediately = false) {
109@@ -1117,9 +1104,7 @@
110 pasted_files_list.prepend (k as File);
111 });
112
113- if (!view.slot.directory.is_local)
114- view.slot.directory.need_reload ();
115-
116+ view.slot.reload (true); /* non-local only */
117 view.select_glib_files (pasted_files_list, pasted_files_list.first ().data);
118 return false;
119 });
120@@ -1472,12 +1457,8 @@
121 if (drop_occurred) {
122 drop_occurred = false;
123 if (current_actions != Gdk.DragAction.DEFAULT) {
124- if (!slot.directory.is_local) {
125- /* Cannot be sure that view will automatically refresh properly
126- * so we force a refresh after a short delay */
127- slot.directory.clear_directory_info ();
128- slot.directory.need_reload ();
129- }
130+ slot.reload (true); /* non-local only */
131+
132 switch (info) {
133 case TargetType.XDND_DIRECT_SAVE0:
134 success = dnd_handler.handle_xdnddirectsave (context,
135@@ -2557,8 +2538,7 @@
136 window.item_hovered (file);
137 hover_path = path;
138 } else {
139- slot.reload ();
140- slot.directory.need_reload ();
141+ slot.reload (true); /* non-local only */
142 }
143 }
144
145@@ -2648,6 +2628,9 @@
146 }
147
148 on_name_editing_canceled ();
149+
150+ if (new_name != original_name)
151+ slot.reload (true); /* non-local only */
152 }
153
154
155@@ -3032,7 +3015,6 @@
156
157 public virtual void cancel () {
158 cancel_thumbnailing ();
159- slot.directory.cancel ();
160 cancel_drag_timer ();
161 cancel_timeout (ref drag_scroll_timer_id);
162
163
164=== modified file 'src/View/Miller.vala'
165--- src/View/Miller.vala 2015-05-26 13:29:17 +0000
166+++ src/View/Miller.vala 2015-06-30 14:19:06 +0000
167@@ -398,8 +398,8 @@
168 ((Marlin.View.Slot)(current_slot)).grab_focus ();
169 }
170
171- public override void reload () {
172- ((Marlin.View.Slot)(current_slot)).reload ();
173+ public override void reload (bool non_local_only = false) {
174+ ((Marlin.View.Slot)(current_slot)).reload (non_local_only);
175 }
176
177 public override void cancel () {
178
179=== modified file 'src/View/Slot.vala'
180--- src/View/Slot.vala 2015-05-26 13:29:17 +0000
181+++ src/View/Slot.vala 2015-06-30 14:19:06 +0000
182@@ -120,7 +120,8 @@
183 }
184
185 private void on_directory_need_reload (GOF.Directory.Async dir) {
186- ctab.reload ();
187+ dir_view.change_directory (directory, directory);
188+ ctab.load_slot_directory (this);
189 }
190
191 private void set_up_directory (GLib.File loc) {
192@@ -189,6 +190,7 @@
193 public override void user_path_change_request (GLib.File loc, bool allow_mode_change = true) {
194 assert (loc != null);
195 var old_dir = directory;
196+ old_dir.cancel ();
197 set_up_directory (loc);
198 dir_view.change_directory (old_dir, directory);
199 /* ViewContainer takes care of updating appearance
200@@ -197,6 +199,13 @@
201 ctab.slot_path_changed (directory.location, allow_mode_change);
202 }
203
204+ public override void reload (bool non_local_only = false) {
205+ if (!(non_local_only && directory.is_local)) {
206+ directory.clear_directory_info ();
207+ directory.need_reload (); /* Signal will propagate to any other slot showing this directory */
208+ }
209+ }
210+
211 protected override void make_view () {
212 assert (dir_view == null);
213
214@@ -291,11 +300,6 @@
215 dir_view.zoom_normal ();
216 }
217
218- public override void reload () {
219- directory.clear_directory_info ();
220- user_path_change_request (location, false);
221- }
222-
223 public override void cancel () {
224 if (directory != null)
225 directory.cancel ();
226
227=== modified file 'src/View/ViewContainer.vala'
228--- src/View/ViewContainer.vala 2015-06-01 15:35:22 +0000
229+++ src/View/ViewContainer.vala 2015-06-30 14:19:06 +0000
230@@ -56,7 +56,7 @@
231 private Browser browser;
232 private GLib.List<GLib.File>? selected_locations = null;
233
234- private bool ready = false;
235+ public bool ready {get; private set;}
236
237 public signal void tab_name_changed (string tab_name);
238 public signal void loading (bool is_loading);
239@@ -64,7 +64,7 @@
240 public signal void path_changed (File file);
241
242 /* Initial location now set by Window.make_tab after connecting signals */
243- public ViewContainer (Marlin.View.Window win, Marlin.ViewMode mode, GLib.File loc) {
244+ public ViewContainer (Marlin.View.Window win) {
245 window = win;
246 overlay_statusbar = new OverlayBar (win, this);
247 browser = new Browser ();
248@@ -77,7 +77,6 @@
249
250 set_events (Gdk.EventMask.ENTER_NOTIFY_MASK | Gdk.EventMask.LEAVE_NOTIFY_MASK);
251 connect_signals ();
252- change_view_mode (mode, loc);
253 }
254
255 ~ViewContainer () {
256@@ -177,7 +176,6 @@
257 }
258
259 public void user_path_change_request (GLib.File loc) {
260- loading (true);
261 view.user_path_change_request (loc);
262 }
263
264@@ -217,7 +215,7 @@
265 return;
266
267 refresh_slot_info (slot);
268-
269+ loading (true);
270 /* Allow time for the window to update before trying to load directory so that
271 * the window is displayed more quickly when starting the application in,
272 * or switching view to, a folder that contains a large number of files.
273@@ -229,7 +227,7 @@
274
275 * Do not try and load directory that is not flagged 'can load'.
276 */
277- Idle.add (() => {
278+ Idle.add_full (GLib.Priority.LOW, () => {
279 if (!slot.directory.is_ready)
280 return true;
281
282@@ -426,23 +424,10 @@
283 }
284
285 public void reload (bool propagate = true) {
286- /* Allow time for the signal to propagate and the tab label to redraw */
287- Idle.add (() => {
288- var slot = get_current_slot ();
289- if (slot == null)
290- return false;
291-
292+ loading (true);
293+ var slot = get_current_slot ();
294+ if (slot != null)
295 slot.reload ();
296- load_slot_directory (slot);
297- /* For remote folders, make sure any other windows showing the same folder are
298- * also refreshed. Prevent infinite loop with propagate - when called from application,
299- * propagate will be false.
300- */
301- if (propagate)
302- ((Marlin.Application)(window.application)).tab_reloaded (window, slot.location);
303-
304- return false;
305- });
306 }
307
308 public Gee.List<string> get_go_back_path_list () {
309
310=== modified file 'src/View/Window.vala'
311--- src/View/Window.vala 2015-06-24 07:49:55 +0000
312+++ src/View/Window.vala 2015-06-30 14:19:06 +0000
313@@ -74,7 +74,6 @@
314 public signal void selection_changed (GLib.List<GOF.File> gof_file);
315 public signal void loading_uri (string location);
316 public signal void folder_deleted (GLib.File location);
317- public signal void tab_reloaded (GLib.File location);
318
319 [Signal (action=true)]
320 public virtual signal void go_up () {
321@@ -379,7 +378,8 @@
322 Marlin.ViewMode mode = Marlin.ViewMode.PREFERRED) {
323 mode = real_mode (mode);
324 update_view_mode (mode);
325- var content = new View.ViewContainer (this, mode, location);
326+
327+ var content = new View.ViewContainer (this);
328 var tab = new Granite.Widgets.Tab ("", null, content);
329
330 content.tab_name_changed.connect ((tab_name) => {
331@@ -391,9 +391,12 @@
332 top_menu.location_bar.bread.show_refresh_icon (!is_loading);
333 });
334
335+ content.update_tab_name (location);
336+ content.change_view_mode (mode, location);
337+
338 change_tab ((int)tabs.insert_tab (tab, -1));
339- content.update_tab_name (location);
340 tabs.current = tab;
341+
342 /* The following fixes a bug where upon first opening
343 a tab, the overlay status bar is shown empty. */
344 item_hovered (null);
345@@ -460,15 +463,12 @@
346 (application as Marlin.Application).quit ();
347 }
348
349- private uint reload_timeout_id = 0;
350 private void action_reload (GLib.SimpleAction action, GLib.Variant? param) {
351 /* avoid spawning reload when key kept pressed */
352- if (reload_timeout_id == 0)
353- reload_timeout_id = Timeout.add (90, () => {
354- current_tab.reload ();
355- reload_timeout_id = 0;
356- return false;
357- });
358+ if (tabs.current.working || !current_tab.ready)
359+ return;
360+
361+ current_tab.reload ();
362 }
363
364 private void action_view_mode (GLib.SimpleAction action, GLib.Variant? param) {

Subscribers

People subscribed via source and target branches

to all changes: