From e7802f2f56f28db3cb93230da63d6f254d401c93 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 22 Aug 2024 11:24:16 +0800 Subject: [PATCH 1/3] Fix ASAN with MSVC --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b062604fba6..197694e0208 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,6 +314,8 @@ if (SLIC3R_ASAN) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address") + else() + add_compile_definitions(_DISABLE_STRING_ANNOTATION=1 _DISABLE_VECTOR_ANNOTATION=1) endif () if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") From 44f8d70a7e00d83a2a427b70018b4bfc87cdbf8e Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Thu, 22 Aug 2024 11:24:31 +0800 Subject: [PATCH 2/3] Make ASAN happy --- src/slic3r/GUI/PartPlate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index ce658119360..f99db5445c8 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -470,7 +470,7 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox int count = 0; int step = 10; // Orca: use 500 x 500 bed size as baseline. - auto grid_counts = pp_bbox.size() / ((coord_t) scale_(step * 50)); + const Point grid_counts = pp_bbox.size() / ((coord_t) scale_(step * 50)); // if the grid is too dense, we increase the step if (grid_counts.minCoeff() > 1) { step = static_cast(grid_counts.minCoeff() + 1) * 10; From c1216ac2b9eb611b79f4c5ff142b4fd023c23c9b Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Fri, 23 Aug 2024 09:26:25 +0800 Subject: [PATCH 3/3] Avoid deleting activated tab button by not calling `DeleteAllItems` (#SoftFever/OrcaSlicer#6486) --- src/slic3r/GUI/Tab.cpp | 17 +++++++++++++---- src/slic3r/GUI/Widgets/TabCtrl.cpp | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 9ac8e4bdbd2..fc37a0ea6be 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -4746,19 +4746,28 @@ void Tab::rebuild_page_tree() // To avoid redundant clear/activate functions call // suppress activate page before page_tree rebuilding m_disable_tree_sel_changed_event = true; - m_tabctrl->DeleteAllItems(); + int curr_item = 0; for (auto p : m_pages) { if (!p->get_show()) continue; - auto itemId = m_tabctrl->AppendItem(translate_category(p->title(), m_type), p->iconID()); - m_tabctrl->SetItemTextColour(itemId, p->get_item_colour() == m_modified_label_clr ? p->get_item_colour() : StateColor( + if (m_tabctrl->GetCount() <= curr_item) { + m_tabctrl->AppendItem(translate_category(p->title(), m_type), p->iconID()); + } else { + m_tabctrl->SetItemText(curr_item, translate_category(p->title(), m_type)); + } + m_tabctrl->SetItemTextColour(curr_item, p->get_item_colour() == m_modified_label_clr ? p->get_item_colour() : StateColor( std::make_pair(0x6B6B6C, (int) StateColor::NotChecked), std::make_pair(p->get_item_colour(), (int) StateColor::Normal))); if (translate_category(p->title(), m_type) == selected) - item = itemId; + item = curr_item; + curr_item++; } + while (m_tabctrl->GetCount() > curr_item) { + m_tabctrl->DeleteItem(m_tabctrl->GetCount() - 1); + } + // BBS: on mac, root is selected, this fix it m_tabctrl->Unselect(); // BBS: not select on hide tab diff --git a/src/slic3r/GUI/Widgets/TabCtrl.cpp b/src/slic3r/GUI/Widgets/TabCtrl.cpp index 73d792a4e09..1cfb8c55346 100644 --- a/src/slic3r/GUI/Widgets/TabCtrl.cpp +++ b/src/slic3r/GUI/Widgets/TabCtrl.cpp @@ -117,7 +117,23 @@ int TabCtrl::AppendItem(const wxString &item, bool TabCtrl::DeleteItem(int item) { - return false; + if (item < 0 || item >= btns.size()) { + return false; + } + + Button* btn = btns[item]; + btn->Destroy(); + btns.erase(btns.begin() + item); + sizer->Remove(item * 2); + if (btns.size() > 1) + sizer->GetItem(sizer->GetItemCount() - 1)->SetMinSize({0, 0}); + relayout(); + if (sel >= item) { + sel--; + sendTabCtrlEvent(); + } + + return true; } void TabCtrl::DeleteAllItems()