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:
Noisyfox
2024-08-23 22:55:10 +08:00
committed by GitHub
parent d1b9ef427e
commit a68fc86c4e
4 changed files with 33 additions and 6 deletions

View File

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