void AssemblyItem::do_delete() { if (!allows_deletion()) return; const char* assembly_name = m_assembly.get_name(); if (ask_assembly_deletion_confirmation(assembly_name) != QMessageBox::Yes) return; const UniqueID assembly_uid = m_assembly.get_uid(); // Remove all assembly instances and their corresponding project items. remove_assembly_instances( m_project_builder.get_item_registry(), m_parent, assembly_uid); // Remove and delete the assembly. m_parent.assemblies().remove(assembly_uid); // Mark the project as modified. m_project_builder.notify_project_modification(); // Remove and delete the assembly item. ItemBase* assembly_item = m_project_builder.get_item_registry().get_item(assembly_uid); m_project_builder.get_item_registry().remove(assembly_uid); delete assembly_item; // At this point 'this' no longer exists. }
void AssemblyItem::do_delete() { if (!allows_deletion()) return; const char* assembly_name = m_assembly.get_name(); if (ask_assembly_deletion_confirmation(assembly_name) != QMessageBox::Yes) return; const UniqueID assembly_uid = m_assembly.get_uid(); // Remove all assembly instances and their corresponding project items. remove_assembly_instances( m_editor_context.m_item_registry, m_parent, assembly_uid); // Remove and delete the assembly. m_parent.assemblies().remove(assembly_uid); // Mark the project as modified. m_editor_context.m_project_builder.slot_notify_project_modification(); // Remove and delete the assembly item. delete this; }
void AssemblyItem::slot_delete() { if (!allows_deletion()) return; const char* assembly_name = impl->m_assembly->get_name(); if (ask_assembly_deletion_confirmation(assembly_name) != QMessageBox::Yes) return; impl->m_project_builder.remove_assembly(impl->m_assembly->get_uid()); // 'this' no longer exists at this point. }