From 1dc0e3dda86ba07dedbf13568d6ee6cbd6d31f2b Mon Sep 17 00:00:00 2001 From: alves Date: Wed, 4 Mar 2026 17:08:33 +0800 Subject: [PATCH] fix linux crash bug,update linux version info. --- ...thub.Snapmaker.Snapmaker_Orca.metainfo.xml | 4 ++-- src/slic3r/GUI/GUI_Utils.cpp | 20 +++++++++++++++++++ src/slic3r/GUI/ObjectDataViewModel.cpp | 3 +++ src/slic3r/GUI/PrinterCloudAuthDialog.cpp | 3 ++- src/slic3r/GUI/WebGuideDialog.cpp | 5 +++-- src/slic3r/GUI/WebPresetDialog.cpp | 3 ++- src/slic3r/GUI/WebSMUserLoginDialog.cpp | 3 ++- src/slic3r/GUI/WebUserLoginDialog.cpp | 3 ++- 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/scripts/flatpak/io.github.Snapmaker.Snapmaker_Orca.metainfo.xml b/scripts/flatpak/io.github.Snapmaker.Snapmaker_Orca.metainfo.xml index 89142a3518..452d3dc67b 100644 --- a/scripts/flatpak/io.github.Snapmaker.Snapmaker_Orca.metainfo.xml +++ b/scripts/flatpak/io.github.Snapmaker.Snapmaker_Orca.metainfo.xml @@ -38,9 +38,9 @@ #009688 - + -

Version 2.2.1 release with improvements and bug fixes.

+

Version 2.2.4 release with improvements and bug fixes.

diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index d9d4c8143c..43fac34f94 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -330,11 +330,25 @@ bool CheckboxFileDialog::get_checkbox_value() const } +// GTK requires width >= -1 and height > 0 for gtk_window_resize/set_size_request. +// Use minimum 100 to avoid 0 or negative dimensions from bad config or Intersect(). +static const int WINDOW_MIN_WIDTH = 100; +static const int WINDOW_MIN_HEIGHT = 100; + +static void clamp_rect_to_minimum_size(wxRect &rect) +{ + if (rect.width < WINDOW_MIN_WIDTH) + rect.width = WINDOW_MIN_WIDTH; + if (rect.height < WINDOW_MIN_HEIGHT) + rect.height = WINDOW_MIN_HEIGHT; +} + WindowMetrics WindowMetrics::from_window(wxTopLevelWindow *window) { WindowMetrics res; res.rect = window->GetScreenRect(); res.maximized = window->IsMaximized(); + clamp_rect_to_minimum_size(res.rect); return res; } @@ -362,6 +376,7 @@ boost::optional WindowMetrics::deserialize(const std::string &str WindowMetrics res; res.rect = wxRect(metrics[0], metrics[1], metrics[2], metrics[3]); + clamp_rect_to_minimum_size(res.rect); res.maximized = metrics[4] != 0; return res; @@ -370,6 +385,11 @@ boost::optional WindowMetrics::deserialize(const std::string &str void WindowMetrics::sanitize_for_display(const wxRect &screen_rect) { rect = rect.Intersect(screen_rect); + // Intersect can yield 0 or negative width/height; GTK asserts on that. + clamp_rect_to_minimum_size(rect); + // Keep within display (e.g. after monitor change) + rect.x = std::max(screen_rect.x, std::min(rect.x, screen_rect.x + screen_rect.width - rect.width)); + rect.y = std::max(screen_rect.y, std::min(rect.y, screen_rect.y + screen_rect.height - rect.height)); // Prevent the window from going too far towards the right and/or bottom edge // It's hardcoded here that the threshold is 80% of the screen size diff --git a/src/slic3r/GUI/ObjectDataViewModel.cpp b/src/slic3r/GUI/ObjectDataViewModel.cpp index 80a92a703a..da770bc1a0 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.cpp +++ b/src/slic3r/GUI/ObjectDataViewModel.cpp @@ -554,6 +554,9 @@ void ObjectDataViewModel::UpdateBitmapForNode(ObjectDataViewModelNode *node) scaled_bitmap_name += std::to_string(vol_type); scaled_bitmap_name += (wxGetApp().dark_mode() ? "-dm" : "-lm"); + if (!m_bitmap_cache) + return; + wxBitmap* bmp = m_bitmap_cache->find(scaled_bitmap_name); if (bmp == nullptr) { std::vector bmps; diff --git a/src/slic3r/GUI/PrinterCloudAuthDialog.cpp b/src/slic3r/GUI/PrinterCloudAuthDialog.cpp index 4d29d9b1c1..2cc364c724 100644 --- a/src/slic3r/GUI/PrinterCloudAuthDialog.cpp +++ b/src/slic3r/GUI/PrinterCloudAuthDialog.cpp @@ -37,7 +37,8 @@ PrinterCloudAuthDialog::PrinterCloudAuthDialog(wxWindow* parent, PrintHost* host return; } m_browser->Hide(); - m_browser->SetSize(0, 0); + // GTK asserts on width < -1 and height <= 0; use minimal size for hidden widget + m_browser->SetSize(1, 1); // Connect the webview events Bind(wxEVT_WEBVIEW_NAVIGATING, &PrinterCloudAuthDialog::OnNavigationRequest, this, m_browser->GetId()); diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 9a67906dba..9ecdbf7afd 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -134,7 +134,8 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style) return; } m_browser->Hide(); - m_browser->SetSize(0, 0); + // GTK asserts on width < -1 and height <= 0; use minimal size for hidden widget + m_browser->SetSize(1, 1); SetSizer(topsizer); @@ -496,7 +497,7 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) } } - wxGetApp().fltviews().reload_all(); + wxGetApp().fltviews().relead_all(); } this->EndModal(wxID_OK); diff --git a/src/slic3r/GUI/WebPresetDialog.cpp b/src/slic3r/GUI/WebPresetDialog.cpp index b8f07a3da8..07dd13c627 100644 --- a/src/slic3r/GUI/WebPresetDialog.cpp +++ b/src/slic3r/GUI/WebPresetDialog.cpp @@ -138,7 +138,8 @@ WebPresetDialog::WebPresetDialog(GUI_App* pGUI, long style) return; } m_browser->Hide(); - m_browser->SetSize(0, 0); + // GTK asserts on width < -1 and height <= 0; use minimal size for hidden widget + m_browser->SetSize(1, 1); SetSizer(topsizer); diff --git a/src/slic3r/GUI/WebSMUserLoginDialog.cpp b/src/slic3r/GUI/WebSMUserLoginDialog.cpp index 9cf1474d8a..9e7bc28ce4 100644 --- a/src/slic3r/GUI/WebSMUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebSMUserLoginDialog.cpp @@ -75,7 +75,8 @@ SMUserLogin::SMUserLogin(bool isLogout) : wxDialog((wxWindow *) (wxGetApp().main return; } m_browser->Hide(); - m_browser->SetSize(0, 0); + // GTK asserts on width < -1 and height <= 0; use minimal size for hidden widget + m_browser->SetSize(1, 1); // Log backend information // wxLogMessage(wxWebView::GetBackendVersionInfo().ToString()); diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index f0118926f2..207cc7a456 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -98,7 +98,8 @@ ZUserLogin::ZUserLogin() : wxDialog((wxWindow *) (wxGetApp().mainframe), wxID_AN return; } m_browser->Hide(); - m_browser->SetSize(0, 0); + // GTK asserts on width < -1 and height <= 0; use minimal size for hidden widget + m_browser->SetSize(1, 1); // Log backend information // wxLogMessage(wxWebView::GetBackendVersionInfo().ToString());