Fix split to objects crash (#9066)

* Fix split to objects crash (SoftFever/OrcaSlicer#9047)

* Avoid unnecessary trigger of `ObjectList::list_manipulation` when object selection changed programmly
This commit is contained in:
Noisyfox 2025-04-03 21:55:44 +08:00 committed by GitHub
parent 8698f75144
commit b4c17d6e97
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -1192,6 +1192,8 @@ void ObjectList::OnContextMenu(wxDataViewEvent& evt)
void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_menu/* = false*/)
{
if (m_prevent_list_manipulation) return;
// Interesting fact: when mouse_pos.x < 0, HitTest(mouse_pos, item, col) returns item = null, but column = last column.
// So, when mouse was moved to scene immediately after clicking in ObjectList, in the scene will be shown context menu for the Editing column.
if (mouse_pos.x < 0)
@ -1289,7 +1291,7 @@ void ObjectList::list_manipulation(const wxPoint& mouse_pos, bool evt_context_me
dynamic_cast<TabPrintPlate*>(wxGetApp().get_plate_tab())->reset_model_config();
else if (m_objects_model->GetItemType(item) & itLayer)
dynamic_cast<TabPrintLayer*>(wxGetApp().get_layer_tab())->reset_model_config();
else
else if (item.IsOk())
dynamic_cast<TabPrintModel*>(wxGetApp().get_model_tab(vol_idx >= 0))->reset_model_config();
}
else if (col_num == colName)
@ -4668,6 +4670,7 @@ void ObjectList::select_item(std::function<wxDataViewItem()> get_item)
return;
m_prevent_list_events = true;
m_prevent_list_manipulation = true;
wxDataViewItem item = get_item();
if (item.IsOk()) {
@ -4676,6 +4679,7 @@ void ObjectList::select_item(std::function<wxDataViewItem()> get_item)
part_selection_changed();
}
m_prevent_list_manipulation = false;
m_prevent_list_events = false;
}
@ -4728,6 +4732,7 @@ void ObjectList::select_items(const std::vector<ObjectVolumeID>& ov_ids)
void ObjectList::select_items(const wxDataViewItemArray& sels)
{
m_prevent_list_events = true;
m_prevent_list_manipulation = true;
m_last_selected_item = sels.empty() ? wxDataViewItem(nullptr) : sels.back();
UnselectAll();
@ -4742,6 +4747,7 @@ void ObjectList::select_items(const wxDataViewItemArray& sels)
part_selection_changed();
m_prevent_list_manipulation = false;
m_prevent_list_events = false;
}

View File

@ -175,6 +175,7 @@ private:
bool m_prevent_list_events = false; // We use this flag to avoid circular event handling Select()
// happens to fire a wxEVT_LIST_ITEM_SELECTED on OSX, whose event handler
// calls this method again and again and again
bool m_prevent_list_manipulation = false;
bool m_prevent_update_filament_in_config = false; // We use this flag to avoid updating of the extruder value in config
// during updating of the extruder count.