From ffee4024941006da85c10109826607d8bb44d40a Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 19 Aug 2026 00:27:48 +0800 Subject: [PATCH] Give the printer-agents web Device tab its own page id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In printer-agents mode the legacy web page was appended under Notebook::PAGE_MONITOR, which resolves to the same "monitor" id as the native Device tab. FindPageByName returns the first match, so PluginPages::relayout() — which saves the selection by name and restores it after rebuilding the tab strip — moved the user off the web tab onto the native one. The tab also disagreed with its own label, being created as "Device (legacy)" and renamed to "Device (Web)" on the next show_device() call. --- src/slic3r/GUI/MainFrame.cpp | 5 +++-- src/slic3r/GUI/MainFrame.hpp | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 334bd9f3d4..9e3d40994b 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1385,7 +1385,7 @@ void MainFrame::show_device(bool should_use_native) { // The web page is appended when printer agents are enabled. Remove that // extra page before switching back to the normal native/Web layout. if (!use_printer_agents) { - if ((idx = m_tabpanel->FindPage(m_printer_view)) != wxNOT_FOUND && idx != m_tabpanel->FindPageByName(TAB_ID_MONITOR)) { + if ((idx = m_tabpanel->FindPageByName(TAB_ID_MONITOR_WEB)) != wxNOT_FOUND) { m_printer_view->Show(false); m_tabpanel->RemovePage(idx); } @@ -1447,7 +1447,8 @@ void MainFrame::show_device(bool should_use_native) { if ((idx = m_tabpanel->FindPage(m_printer_view)) == wxNOT_FOUND) { m_printer_view->Show(false); - m_tabpanel->AddPage(m_printer_view, _L("Device (legacy)"), false, Notebook::PAGE_MONITOR); + m_tabpanel->InsertPage(m_tabpanel->GetPageCount(), TAB_ID_MONITOR_WEB, m_printer_view, + _L("Device (Web)"), "tab_monitor_active", false); } else { m_tabpanel->SetPageText(idx, _L("Device (Web)")); } diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 6d8e548ce8..d6e8173288 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -43,6 +43,10 @@ #define TAB_ID_PREPARE "prepare" #define TAB_ID_PREVIEW "preview" #define TAB_ID_MONITOR "monitor" +// Printer-agents mode shows the legacy web page alongside the native Device tab, so it needs an +// id of its own: sharing TAB_ID_MONITOR makes every name lookup resolve to whichever of the two +// comes first, which silently defeats PluginPages' selection round-trip across a tab relayout. +#define TAB_ID_MONITOR_WEB "monitor_web" #define TAB_ID_MULTI_DEVICE "multi_device" #define TAB_ID_PROJECT "project" #define TAB_ID_CALIBRATION "calibration"