review result part 0: -Wuse-after-free vs wxWidget

This commit is contained in:
Raoul Rubien 2025-12-21 11:38:24 +01:00 committed by Dipl.-Ing. Raoul Rubien, BSc
parent 18aee83ca0
commit cff6dd5502

View file

@ -1048,8 +1048,12 @@ wxDataViewItem ObjectDataViewModel::Delete(const wxDataViewItem &item)
ObjectDataViewModelNode* last_instance_node = node_parent->GetNthChild(0);
PrintIndicator last_instance_printable = last_instance_node->IsPrintable();
node_parent->GetChildren().Remove(last_instance_node);
ItemDeleted(parent, wxDataViewItem(last_instance_node));
delete last_instance_node;
// `delete` before `ItemDeleted()` is valid wxWidget pattern
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
ItemDeleted(parent, wxDataViewItem(last_instance_node));
#pragma GCC diagnostic pop
ObjectDataViewModelNode* obj_node = node_parent->GetParent();
obj_node->set_printable_icon(last_instance_printable);