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()); } } }