diff --git a/src/mkvtoolnix-gui/header_editor/page_model.cpp b/src/mkvtoolnix-gui/header_editor/page_model.cpp index c8db83ef5..539d8d044 100644 --- a/src/mkvtoolnix-gui/header_editor/page_model.cpp +++ b/src/mkvtoolnix-gui/header_editor/page_model.cpp @@ -50,6 +50,18 @@ PageModel::appendPage(PageBase *page, m_topLevelPages << page; } +bool +PageModel::deletePage(PageBase *page) { + auto idx = m_pages.indexOf(page); + if (idx == -1) + return false; + + m_pages.removeAt(idx); + delete page; + + return true; +} + QList & PageModel::pages() { return m_pages; diff --git a/src/mkvtoolnix-gui/header_editor/page_model.h b/src/mkvtoolnix-gui/header_editor/page_model.h index a84cf17e0..c2d2b70fa 100644 --- a/src/mkvtoolnix-gui/header_editor/page_model.h +++ b/src/mkvtoolnix-gui/header_editor/page_model.h @@ -24,6 +24,7 @@ public: PageBase *selectedPage(QModelIndex const &idx) const; void appendPage(PageBase *page, QModelIndex const &parentIdx = {}); + bool deletePage(PageBase *page); QList &pages(); QList &topLevelPages(); diff --git a/src/mkvtoolnix-gui/header_editor/tab.cpp b/src/mkvtoolnix-gui/header_editor/tab.cpp index 0473f22a5..239153e79 100644 --- a/src/mkvtoolnix-gui/header_editor/tab.cpp +++ b/src/mkvtoolnix-gui/header_editor/tab.cpp @@ -633,8 +633,7 @@ Tab::removeSelectedAttachment() { m_model->removeRow(idx.row(), idx.parent()); m_attachmentsPage->m_children.removeAll(selectedPage); - - delete selectedPage; + m_model->deletePage(selectedPage); } KaxAttachedPtr