Fix usage of Reference dialog:

+ fix memory leak by using QDialog on the stack
+ open a transaction where needed when making a copy to avoid mess with undo/redo
+ set proper title and use main window as parent
+ replace class name Dialog with PartDesignGui::DlgReference
This commit is contained in:
wmayer
2018-12-03 17:54:05 +01:00
parent 2246e73488
commit 7683bb2b4f
5 changed files with 99 additions and 97 deletions

View File

@@ -50,6 +50,7 @@
#include <Base/Console.h>
#include <Gui/Selection.h>
#include <Gui/Command.h>
#include <Gui/MainWindow.h>
#include <Mod/PartDesign/App/FeaturePipe.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Mod/PartDesign/App/Body.h>
@@ -805,9 +806,6 @@ TaskDlgPipeParameters::~TaskDlgPipeParameters()
bool TaskDlgPipeParameters::accept()
{
std::string name = vp->getObject()->getNameInDocument();
//see what to do with external references
//check the prerequisites for the selected objects
//the user has to decide which option we should take if external references are used
@@ -816,26 +814,26 @@ bool TaskDlgPipeParameters::accept()
//auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);
std::vector<App::DocumentObject*> copies;
bool ext = false;
bool extReference = false;
if(!pcActiveBody->hasObject(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue()))
ext = true;
extReference = true;
else if(pcPipe->AuxillerySpine.getValue() && !pcActiveBody->hasObject(pcPipe->AuxillerySpine.getValue()) &&
!pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue()))
ext = true;
extReference = true;
else {
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {
if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj))
ext = true;
extReference = true;
}
}
if(ext) {
QDialog* dia = new QDialog;
Ui_Dialog dlg;
dlg.setupUi(dia);
dia->setModal(true);
int result = dia->exec();
if(result == QDialog::DialogCode::Rejected)
if (extReference) {
QDialog dia(Gui::getMainWindow());
Ui_DlgReference dlg;
dlg.setupUi(&dia);
dia.setModal(true);
int result = dia.exec();
if (result == QDialog::DialogCode::Rejected)
return false;
else if(!dlg.radioXRef->isChecked()) {