From 52438c7cea2bd1203abea40666c3348a29e8fe9b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 5 Nov 2026 06:11:21 -0800 Subject: [PATCH] Fix item 1747: stop hidden thumbnail panel jobs --- crates/ui-egui/src/panel_docking.rs | 10 ++++++++++ crates/ui-egui/src/panel_docking/tests.rs | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index 4b9a5ad14..87f3583d0 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -270,6 +270,11 @@ pub(crate) fn showing(ui: &UiState, panel: &str) -> bool { (ui.open_panel.as_deref() == Some(panel) && iconic) || (!iconic && layout.panel_state(&panel.to_string()) == craft_ui::docking::PanelState::Front) } +/// Can either panel that uses row thumbnails be seen, including in a floating window or flyout? +fn thumbnail_panel_showing(ui: &UiState) -> bool { + ui.dock && ui.screen_mode < 3 && (showing(ui, "layers") || showing(ui, "links")) +} + /// Where a panel with no other destination goes: a panel of the first expanded dock column, /// else of any column. fn first_dock_panel(layout: &Layout, except: &str) -> Option { @@ -1173,6 +1178,11 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) { app.open_dropped_files(window.dropped, None, shift); } forward_keys(app, &ctx, output.forwarded_events, output.forwarded_modifiers); + if !thumbnail_panel_showing(&app.ui) { + // No panel can ask for these rows again this pass. Keep the cache of open documents, but + // discard worker jobs queued behind the one already rendering. + crate::panels::layers::show_thumbs_of(None); + } } /// Whether a modal is open: a dialog, About, the command palette, a native file dialog, or a diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index f8287944b..3afb41f96 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -161,6 +161,25 @@ fn a_tab_dragged_out_floats_and_comes_back_where_it_was_after_its_window_closes( assert!(h.tab("layers").is_some()); } +#[test] +fn thumbnail_work_is_needed_only_while_layers_or_links_can_be_seen() { + let mut h = Harness::new(); + h.app.run("window.panel", json!({"panel": "layers"})).unwrap(); + assert!(thumbnail_panel_showing(&h.app.ui)); + h.app.ui.dock = false; + assert!(!thumbnail_panel_showing(&h.app.ui), "Tab hides every panel"); + h.app.ui.dock = true; + h.app.ui.screen_mode = 3; + assert!(!thumbnail_panel_showing(&h.app.ui), "presentation mode hides panels"); + h.app.ui.screen_mode = 0; + h.app.run("window.panel.float", json!({"panel": "layers"})).unwrap(); + assert!(thumbnail_panel_showing(&h.app.ui), "a floating Layers panel still needs thumbnails"); + h.app.run("window.panel", json!({"panel": "layers", "toggle": true})).unwrap(); + assert!(!thumbnail_panel_showing(&h.app.ui)); + h.app.run("window.panel", json!({"panel": "links"})).unwrap(); + assert!(thumbnail_panel_showing(&h.app.ui), "the Links flyout also uses row thumbnails"); +} + /// A Character field shortcut with the Character panel in front of its floating window brings /// that window forward and leaves the panel showing. #[test]