Fix crash in printer config when switching tabs (#6537)
* Fix ASAN with MSVC * Make ASAN happy * Avoid deleting activated tab button by not calling `DeleteAllItems` (#SoftFever/OrcaSlicer#6486)
This commit is contained in:
parent
d1b9ef427e
commit
a68fc86c4e
4 changed files with 33 additions and 6 deletions
|
@ -314,6 +314,8 @@ if (SLIC3R_ASAN)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_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")
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
|
||||||
|
else()
|
||||||
|
add_compile_definitions(_DISABLE_STRING_ANNOTATION=1 _DISABLE_VECTOR_ANNOTATION=1)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
|
|
|
@ -470,7 +470,7 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int step = 10;
|
int step = 10;
|
||||||
// Orca: use 500 x 500 bed size as baseline.
|
// 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 the grid is too dense, we increase the step
|
||||||
if (grid_counts.minCoeff() > 1) {
|
if (grid_counts.minCoeff() > 1) {
|
||||||
step = static_cast<int>(grid_counts.minCoeff() + 1) * 10;
|
step = static_cast<int>(grid_counts.minCoeff() + 1) * 10;
|
||||||
|
|
|
@ -4746,19 +4746,28 @@ void Tab::rebuild_page_tree()
|
||||||
// To avoid redundant clear/activate functions call
|
// To avoid redundant clear/activate functions call
|
||||||
// suppress activate page before page_tree rebuilding
|
// suppress activate page before page_tree rebuilding
|
||||||
m_disable_tree_sel_changed_event = true;
|
m_disable_tree_sel_changed_event = true;
|
||||||
m_tabctrl->DeleteAllItems();
|
|
||||||
|
|
||||||
|
int curr_item = 0;
|
||||||
for (auto p : m_pages)
|
for (auto p : m_pages)
|
||||||
{
|
{
|
||||||
if (!p->get_show())
|
if (!p->get_show())
|
||||||
continue;
|
continue;
|
||||||
auto itemId = m_tabctrl->AppendItem(translate_category(p->title(), m_type), p->iconID());
|
if (m_tabctrl->GetCount() <= curr_item) {
|
||||||
m_tabctrl->SetItemTextColour(itemId, p->get_item_colour() == m_modified_label_clr ? p->get_item_colour() : StateColor(
|
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(0x6B6B6C, (int) StateColor::NotChecked),
|
||||||
std::make_pair(p->get_item_colour(), (int) StateColor::Normal)));
|
std::make_pair(p->get_item_colour(), (int) StateColor::Normal)));
|
||||||
if (translate_category(p->title(), m_type) == selected)
|
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
|
// BBS: on mac, root is selected, this fix it
|
||||||
m_tabctrl->Unselect();
|
m_tabctrl->Unselect();
|
||||||
// BBS: not select on hide tab
|
// BBS: not select on hide tab
|
||||||
|
|
|
@ -117,7 +117,23 @@ int TabCtrl::AppendItem(const wxString &item,
|
||||||
|
|
||||||
bool TabCtrl::DeleteItem(int 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()
|
void TabCtrl::DeleteAllItems()
|
||||||
|
|
Loading…
Reference in a new issue