fix linux crash bug,update linux version info.

This commit is contained in:
alves
2026-03-04 17:08:33 +08:00
parent fb9ff36404
commit 1dc0e3dda8
8 changed files with 36 additions and 8 deletions

View File

@@ -38,9 +38,9 @@
<color type="primary" scheme_preference="light">#009688</color>
</branding>
<releases>
<release version="2.2.1" date="2025-12-26">
<release version="2.2.4" date="2026-3-4">
<description>
<p>Version 2.2.1 release with improvements and bug fixes.</p>
<p>Version 2.2.4 release with improvements and bug fixes.</p>
</description>
</release>
</releases>

View File

@@ -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> 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> 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

View File

@@ -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<wxBitmap> bmps;

View File

@@ -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());

View File

@@ -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);

View File

@@ -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);

View File

@@ -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());

View File

@@ -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());