Open the plugin terminal off the webview callback stack

open_terminal_dialog is reached from the plugins dialog's webview
command, and TerminalDialog hosts a webview of its own — same class as
the plugin-window crash. Defer the window work via CallAfter, guard the
re-front Show() per #13657, and drop the redundant Raise() on creation.
This commit is contained in:
SoftFever
2026-07-16 21:25:30 +08:00
parent d9f8460a4e
commit f2ccbfc8b5

View File

@@ -8255,7 +8255,16 @@ void GUI_App::open_plugins_dialog(size_t open_on_tab, const std::string& highlig
void GUI_App::open_terminal_dialog() void GUI_App::open_terminal_dialog()
{ {
// Reached from the plugins dialog's webview ("open_terminal" command), i.e. from
// inside the webview script-message callback, which GTK/macOS deliver synchronously
// (see ui_create_window in PluginHostUi.cpp). TerminalDialog hosts a webview of its
// own, so creating or presenting it on that stack is the same class as the Linux
// gtk_window_present crash — defer all window work to a clean main-loop iteration.
CallAfter([this]() {
if (m_terminal_dlg) { if (m_terminal_dlg) {
// Re-front the existing window; guard Show() per #13657 (GTK re-enters
// layout when showing an already-visible window).
if (!m_terminal_dlg->IsShown())
m_terminal_dlg->Show(); m_terminal_dlg->Show();
m_terminal_dlg->Raise(); m_terminal_dlg->Raise();
return; return;
@@ -8269,8 +8278,9 @@ void GUI_App::open_terminal_dialog()
event.Skip(); event.Skip();
}); });
// Show() alone activates and fronts a freshly created window on every platform.
m_terminal_dlg->Show(); m_terminal_dlg->Show();
m_terminal_dlg->Raise(); });
} }
void GUI_App::open_exportpresetbundledialog(size_t open_on_tab, const std::string& highlight_option) void GUI_App::open_exportpresetbundledialog(size_t open_on_tab, const std::string& highlight_option)