GUI_ObjectList.cpp: Fixed a crash when deleting instances.
Deleting second-but-last instance deletes the whole Instances node, we must select object node in that case.
This commit is contained in:
parent
a48ba21f40
commit
326eb5e343
1 changed files with 7 additions and 4 deletions
|
@ -2500,12 +2500,15 @@ void ObjectList::remove()
|
||||||
auto delete_item = [this](wxDataViewItem item)
|
auto delete_item = [this](wxDataViewItem item)
|
||||||
{
|
{
|
||||||
wxDataViewItem parent = m_objects_model->GetParent(item);
|
wxDataViewItem parent = m_objects_model->GetParent(item);
|
||||||
if (m_objects_model->GetItemType(item) & itObject)
|
ItemType type = m_objects_model->GetItemType(item);
|
||||||
|
if (type & itObject)
|
||||||
delete_from_model_and_list(itObject, m_objects_model->GetIdByItem(item), -1);
|
delete_from_model_and_list(itObject, m_objects_model->GetIdByItem(item), -1);
|
||||||
else {
|
else {
|
||||||
if (m_objects_model->GetItemType(item) & itLayer) {
|
if (type & (itLayer | itInstance)) {
|
||||||
|
// In case there is just one layer or two instances and we delete it, del_subobject_item will
|
||||||
|
// also remove the parent item. Selection should therefore pass to the top parent (object).
|
||||||
wxDataViewItemArray children;
|
wxDataViewItemArray children;
|
||||||
if (m_objects_model->GetChildren(parent, children) == 1)
|
if (m_objects_model->GetChildren(parent, children) == (type & itLayer ? 1 : 2))
|
||||||
parent = m_objects_model->GetTopParent(item);
|
parent = m_objects_model->GetTopParent(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue