From ee912a5f16b2f032a3f716c2c26ae80bf58faa8e Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 18 Oct 2019 15:46:02 +0200 Subject: [PATCH] change deletion order in parameter editor to avoid that a parameter group isn't deleted --- src/Gui/DlgParameterImp.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Gui/DlgParameterImp.cpp b/src/Gui/DlgParameterImp.cpp index eb09ecc2e7..6a9ca967f6 100644 --- a/src/Gui/DlgParameterImp.cpp +++ b/src/Gui/DlgParameterImp.cpp @@ -404,16 +404,21 @@ void ParameterGroup::onDeleteSelectedItem() QTreeWidgetItem* sel = currentItem(); if (isItemSelected(sel) && sel->parent()) { - if ( QMessageBox::question(this, tr("Remove group"), tr("Do really want to remove this parameter group?"), + if ( QMessageBox::question(this, tr("Remove group"), tr("Do you really want to remove this parameter group?"), QMessageBox::Yes, QMessageBox::No|QMessageBox::Default|QMessageBox::Escape) == QMessageBox::Yes ) { QTreeWidgetItem* parent = sel->parent(); int index = parent->indexOfChild(sel); parent->takeChild(index); - ParameterGroupItem* para = static_cast(parent); - para->_hcGrp->RemoveGrp(sel->text(0).toLatin1()); + + std::string groupName = sel->text(0).toLatin1(); + // must delete the tree item here because it and its children still + // hold a reference to the parameter group delete sel; + + ParameterGroupItem* para = static_cast(parent); + para->_hcGrp->RemoveGrp(groupName.c_str()); } } }