Merge lp:~jeremywootten/pantheon-files/further-armour-restore-tabs-function into lp:~elementary-apps/pantheon-files/trunk

Proposed by Jeremy Wootten
Status: Merged
Approved by: Cody Garver
Approved revision: 1632
Merged at revision: 1638
Proposed branch: lp:~jeremywootten/pantheon-files/further-armour-restore-tabs-function
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 200 lines (+49/-35)
2 files modified
src/View/ViewContainer.vala (+32/-24)
src/View/Window.vala (+17/-11)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-files/further-armour-restore-tabs-function
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+240618@code.launchpad.net

Commit message

Perform more checks when restoring tabs

Description of the change

This branch adds some further checks during restoring tabs.

To post a comment you must log in.
1632. By Jeremy Wootten

Stop unnecessary rapid destruction and creation of slots on change tab; Slow down rate of creation of tabs during restore tabs - both likely to cause crashes due to race conditions

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

A further possible cause of the reported crashes on start up with restore tabs has been addressed.
Note that these issues should already be resolved in the the unmerged branch lp:~jeremywootten/pantheon-files/all-views-vala.

Revision history for this message
Cody Garver (codygarver) wrote :

Let's see if we can get more feedback on the bug report(s) once this update goes out

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/View/ViewContainer.vala'
2--- src/View/ViewContainer.vala 2014-10-29 13:59:32 +0000
3+++ src/View/ViewContainer.vala 2014-11-09 18:03:53 +0000
4@@ -32,7 +32,7 @@
5 public GOF.Window.Slot? slot = null;
6 public Marlin.Window.Columns? mwcol = null;
7 Browser browser;
8- public int view_mode = 0;
9+ public int view_mode = -1;
10 public OverlayBar overlay_statusbar;
11
12 //private ulong file_info_callback;
13@@ -48,15 +48,13 @@
14 public ViewContainer (Marlin.View.Window win, GLib.File location, int _view_mode = 0) {
15 window = win;
16 overlay_statusbar = new OverlayBar (win, this);
17- view_mode = _view_mode;
18
19 /* set active tab */
20 browser = new Browser ();
21 label = _("Loading…");
22 window.button_back.fetcher = get_back_menu;
23 window.button_forward.fetcher = get_forward_menu;
24-
25- change_view (view_mode, location);
26+ change_view (_view_mode, location);
27 update_location_state (true);
28
29 this.show_all ();
30@@ -203,14 +201,16 @@
31 bool user_change_rq = location == null;
32 select_childs = null;
33
34+ GOF.Window.Slot? active_slot = get_active_slot ();
35+
36 if (location == null) {
37 /* we re just changing view keep the same location */
38- GOF.Window.Slot? active_slot = get_active_slot ();
39 if (active_slot == null) {
40 warning ("No active slot found - cannot change view");
41 return;
42 }
43 location = active_slot.location;
44+
45 /* store the old selection to restore it */
46 if (slot != null && !content_shown) {
47 unowned List<GOF.File> list = ((FM.Directory.View) slot.view_box).get_selection ();
48@@ -233,12 +233,17 @@
49 Marlin.Window.Columns new_mwcol;
50 GOF.Window.Slot new_slot;
51
52- if (nview == ViewMode.MILLER) {
53- new_mwcol = new Marlin.Window.Columns (location, this);
54- new_slot = new_mwcol.active_slot;
55+ if (nview != view_mode || location != active_slot.location) {
56+ if (nview == ViewMode.MILLER) {
57+ new_mwcol = new Marlin.Window.Columns (location, this);
58+ new_slot = new_mwcol.active_slot;
59+ } else {
60+ new_mwcol = null;
61+ new_slot = new GOF.Window.Slot (location, this);
62+ }
63 } else {
64- new_mwcol = null;
65- new_slot = new GOF.Window.Slot (location, this);
66+ new_mwcol = mwcol;
67+ new_slot = slot;
68 }
69
70 /* automagicly enable icon view for icons keypath */
71@@ -281,11 +286,6 @@
72 slot = new_slot;
73 mwcol = new_mwcol;
74
75- /* Setting up view_mode and its button */
76- view_mode = nview;
77- if (window.top_menu.view_switcher != null)
78- window.top_menu.view_switcher.mode = (ViewMode) view_mode;
79-
80 connect_available_info ();
81 if (slot != null) {
82 slot.directory.done_loading.connect (directory_done_loading);
83@@ -293,6 +293,9 @@
84 }
85 plugin_directory_loaded ();
86
87+ /* Setting up view_mode and its button */
88+ view_mode = nview;
89+
90 switch (nview) {
91 case ViewMode.LIST:
92 slot.make_list_view ();
93@@ -305,6 +308,9 @@
94 break;
95 }
96
97+ if (window.top_menu.view_switcher != null)
98+ window.top_menu.view_switcher.mode = (ViewMode) view_mode;
99+
100 overlay_statusbar.showbar = nview != ViewMode.LIST;
101 }
102
103@@ -334,20 +340,22 @@
104 return slot;
105 }
106
107- public string? get_root_uri () {
108+ public string get_root_uri () {
109+ string path = "";
110 if (mwcol != null)
111- return mwcol.get_root_uri ();
112+ path = mwcol.get_root_uri () ?? "";
113 else if (slot != null)
114- return slot.location.get_uri ();
115+ path = slot.location.get_uri () ?? "";
116
117- return null;
118+ return path;
119 }
120
121- public string? get_tip_uri () {
122+ public string get_tip_uri () {
123+ string path = "";
124 if (mwcol != null)
125- return mwcol.get_tip_uri ();
126- else
127- return "";
128+ path = mwcol.get_tip_uri () ?? "";
129+
130+ return path;
131 }
132
133 public void reload () {
134@@ -355,7 +363,7 @@
135 dir.cancel ();
136 dir.need_reload.disconnect (reload);
137 dir.remove_dir_from_cache ();
138- change_view (view_mode, null);
139+ dir.load ();
140 }
141
142 public void update_location_state (bool save_history) {
143
144=== modified file 'src/View/Window.vala'
145--- src/View/Window.vala 2014-11-02 10:08:26 +0000
146+++ src/View/Window.vala 2014-11-09 18:03:53 +0000
147@@ -342,6 +342,7 @@
148 public void change_tab (int offset) {
149 ViewContainer? old_tab = current_tab;
150 current_tab = (tabs.get_tab_by_index (offset)).page as ViewContainer;
151+
152 if (current_tab == null || old_tab == current_tab)
153 return;
154
155@@ -523,8 +524,8 @@
156 GLib.VariantIter iter = new GLib.VariantIter (tab_info_array);
157 int tabs_added = 0;
158 int viewmode = -1;
159- string root_uri = null;
160- string tip_uri = null;
161+ string? root_uri = null;
162+ string? tip_uri = null;
163
164 /* inhibit unnecessary changes of view and rendering of location bar while restoring tabs
165 * as this causes all sorts of problems */
166@@ -552,20 +553,25 @@
167 viewmode = -1;
168 root_uri = null;
169 tip_uri = null;
170+
171+ /* Prevent too rapid loading of tabs which can cause crashes */
172+ Thread.usleep (100000);
173 }
174
175 freeze_view_changes = false;
176
177+ if (tabs_added < 1)
178+ return 0;
179+
180 int active_tab_position = Preferences.settings.get_int ("active-tab-position");
181- if (active_tab_position >=0 && active_tab_position < tabs_added) {
182- tabs.current = tabs.get_tab_by_index (active_tab_position);
183- change_tab (active_tab_position);
184- }
185-
186- string path;
187- if (current_tab == null)
188- path = "";
189- else {
190+ if (active_tab_position < 0 || active_tab_position >= tabs_added)
191+ active_tab_position = 0;
192+
193+ tabs.current = tabs.get_tab_by_index (active_tab_position);
194+ change_tab (active_tab_position);
195+
196+ string path = "";
197+ if (current_tab != null) {
198 path = current_tab.get_tip_uri ();
199 if (path == "")
200 path = current_tab.get_root_uri ();

Subscribers

People subscribed via source and target branches

to all changes: