Skip to content

Commit

Permalink
[Crash] Check tab created before expand miller view (#2332)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Paul Wootten <jeremy@Proteus-EL07R6-4cf32af9.localdomain>
Co-authored-by: Marius Meisenzahl <meisenzahl@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 16, 2023
1 parent 3553afa commit cb4d5ac
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/View/Window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1233,10 +1233,18 @@ public class Files.View.Window : Hdy.ApplicationWindow {

if (yield add_tab_by_uri (root_uri, mode)) {
restoring_tabs++;
}

if (mode == ViewMode.MILLER_COLUMNS && tip_uri != root_uri) {
expand_miller_view (tip_uri, root_uri);
var tab = tab_view.selected_page;
if (tab != null &&
tab.child != null &&
tip_uri != root_uri) {

var view = ((ViewContainer)(tab.child)).view;
if (view != null && view is Miller) {
expand_miller_view ((Miller)view, tip_uri, root_uri);
}
}
} else {
debug ("Failed to restore tab %s", root_uri);
}

mode = ViewMode.INVALID;
Expand Down Expand Up @@ -1273,11 +1281,8 @@ public class Files.View.Window : Hdy.ApplicationWindow {
return restoring_tabs;
}

private void expand_miller_view (string tip_uri, string unescaped_root_uri) {
private void expand_miller_view (Miller miller_view, string tip_uri, string unescaped_root_uri) {
/* It might be more elegant for Miller.vala to handle this */
var tab = tab_view.selected_page;
var view = (ViewContainer)(tab.child);
var mwcols = (Miller)(view.view) ;
var unescaped_tip_uri = FileUtils.sanitize_path (tip_uri);

if (unescaped_tip_uri == null) {
Expand All @@ -1298,7 +1303,7 @@ public class Files.View.Window : Hdy.ApplicationWindow {
uri += (GLib.Path.DIR_SEPARATOR_S + dir);
gfile = get_file_from_uri (uri);

mwcols.add_location (gfile, mwcols.current_slot); // MillerView can deal with multiple scroll requests
miller_view.add_location (gfile, miller_view.current_slot); // MillerView can deal with multiple scroll requests
}
} else {
warning ("Invalid tip uri for Miller View %s", unescaped_tip_uri);
Expand Down

0 comments on commit cb4d5ac

Please sign in to comment.