Fix new project crash on Windows if multi-extruder printer profile is edited (#9600)

Fix new project crash on Windows if profile is edited
This commit is contained in:
Noisyfox 2025-05-14 11:36:50 +08:00 committed by GitHub
parent 1a5b238ba4
commit 3b658cba3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -590,7 +590,7 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str
} }
// Initialize the page. // Initialize the page.
//BBS: GUI refactor //BBS: GUI refactor
PageShp page(new Page(m_page_view, title, icon_idx, this)); PageShp page = std::make_shared<Page>(m_page_view, title, icon_idx, this);
// page->SetBackgroundStyle(wxBG_STYLE_SYSTEM); // page->SetBackgroundStyle(wxBG_STYLE_SYSTEM);
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// page->SetDoubleBuffered(true); // page->SetDoubleBuffered(true);
@ -6263,8 +6263,12 @@ void Page::update_visibility(ConfigOptionMode mode, bool update_contolls_visibil
#ifdef __WXMSW__ #ifdef __WXMSW__
if (!m_show) return; if (!m_show) return;
// BBS: fix field control position // BBS: fix field control position
wxTheApp->CallAfter([this]() { wxTheApp->CallAfter([wp=std::weak_ptr<Page>(shared_from_this())]() {
for (auto group : m_optgroups) { auto page = wp.lock();
if (!page)
return;
for (auto group : page->m_optgroups) {
if (group->custom_ctrl) group->custom_ctrl->fixup_items_positions(); if (group->custom_ctrl) group->custom_ctrl->fixup_items_positions();
} }
}); });

View file

@ -57,7 +57,7 @@ class OG_CustomCtrl;
// Single Tab page containing a{ vsizer } of{ optgroups } // Single Tab page containing a{ vsizer } of{ optgroups }
// package Slic3r::GUI::Tab::Page; // package Slic3r::GUI::Tab::Page;
using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>; using ConfigOptionsGroupShp = std::shared_ptr<ConfigOptionsGroup>;
class Page// : public wxScrolledWindow class Page: public std::enable_shared_from_this<Page>// : public wxScrolledWindow
{ {
//BBS: GUI refactor //BBS: GUI refactor
wxPanel* m_tab_owner; wxPanel* m_tab_owner;