Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash in printer config when switching tabs #6537

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/PartPlate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Collaborator Author

@Noisyfox Noisyfox Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line caused false address sanitizer exceptions that prevented me from debugging the real poblem so I fixed this. Isn't really related to the crash though.

// if the grid is too dense, we increase the step
if (grid_counts.minCoeff() > 1) {
step = static_cast<int>(grid_counts.minCoeff() + 1) * 10;
Expand Down
17 changes: 13 additions & 4 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion src/slic3r/GUI/Widgets/TabCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down