From be22fb0bc5363faf0b49db632352b546f1b6dd1d Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 16 Sep 2020 12:14:04 +0200 Subject: [PATCH] Part: do not use local event loop in sweep and thickness panel --- src/Mod/Part/Gui/TaskOffset.ui | 3 +++ src/Mod/Part/Gui/TaskSweep.cpp | 13 +++++-------- src/Mod/Part/Gui/TaskSweep.h | 2 +- src/Mod/Part/Gui/TaskSweep.ui | 3 +++ src/Mod/Part/Gui/TaskThickness.cpp | 13 +++++-------- src/Mod/Part/Gui/TaskThickness.h | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Mod/Part/Gui/TaskOffset.ui b/src/Mod/Part/Gui/TaskOffset.ui index 48a37ae0d9..fece27eedb 100644 --- a/src/Mod/Part/Gui/TaskOffset.ui +++ b/src/Mod/Part/Gui/TaskOffset.ui @@ -113,6 +113,9 @@ Faces + + true + diff --git a/src/Mod/Part/Gui/TaskSweep.cpp b/src/Mod/Part/Gui/TaskSweep.cpp index f3f4fd0903..0ba958f34e 100644 --- a/src/Mod/Part/Gui/TaskSweep.cpp +++ b/src/Mod/Part/Gui/TaskSweep.cpp @@ -25,7 +25,6 @@ #ifndef _PreComp_ # include -# include # include # include # include @@ -64,7 +63,6 @@ class SweepWidget::Private { public: Ui_TaskSweep ui; - QEventLoop loop; QString buttonText; std::string document; Private() @@ -148,6 +146,7 @@ SweepWidget::SweepWidget(QWidget* parent) SweepWidget::~SweepWidget() { delete d; + Gui::Selection().rmvSelectionGate(); } void SweepWidget::findShapes() @@ -272,7 +271,7 @@ bool SweepWidget::isPathValid(const Gui::SelectionObject& sel) const bool SweepWidget::accept() { - if (d->loop.isRunning()) + if (d->ui.buttonPath->isChecked()) return false; Gui::SelectionFilter edgeFilter ("SELECT Part::Feature SUBELEMENT Edge COUNT 1.."); Gui::SelectionFilter partFilter ("SELECT Part::Feature COUNT 1"); @@ -361,7 +360,7 @@ bool SweepWidget::accept() bool SweepWidget::reject() { - if (d->loop.isRunning()) + if (d->ui.buttonPath->isChecked()) return false; return true; } @@ -378,9 +377,9 @@ void SweepWidget::onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem } } -void SweepWidget::on_buttonPath_clicked() +void SweepWidget::on_buttonPath_toggled(bool on) { - if (!d->loop.isRunning()) { + if (on) { QList c = this->findChildren(); for (QList::iterator it = c.begin(); it != c.end(); ++it) (*it)->setEnabled(false); @@ -392,7 +391,6 @@ void SweepWidget::on_buttonPath_clicked() Gui::Selection().clearSelection(); Gui::Selection().addSelectionGate(new Private::EdgeSelection()); - d->loop.exec(); } else { QList c = this->findChildren(); @@ -401,7 +399,6 @@ void SweepWidget::on_buttonPath_clicked() d->ui.buttonPath->setText(d->buttonText); d->ui.labelPath->clear(); Gui::Selection().rmvSelectionGate(); - d->loop.quit(); Gui::SelectionFilter edgeFilter ("SELECT Part::Feature SUBELEMENT Edge COUNT 1.."); Gui::SelectionFilter partFilter ("SELECT Part::Feature COUNT 1"); diff --git a/src/Mod/Part/Gui/TaskSweep.h b/src/Mod/Part/Gui/TaskSweep.h index 97f68e9ae0..d8c71f355d 100644 --- a/src/Mod/Part/Gui/TaskSweep.h +++ b/src/Mod/Part/Gui/TaskSweep.h @@ -48,7 +48,7 @@ public: private Q_SLOTS: void onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*); - void on_buttonPath_clicked(); + void on_buttonPath_toggled(bool); private: void changeEvent(QEvent *e); diff --git a/src/Mod/Part/Gui/TaskSweep.ui b/src/Mod/Part/Gui/TaskSweep.ui index 0ce3b7c2e2..dc19fdb460 100644 --- a/src/Mod/Part/Gui/TaskSweep.ui +++ b/src/Mod/Part/Gui/TaskSweep.ui @@ -22,6 +22,9 @@ Sweep Path + + true + diff --git a/src/Mod/Part/Gui/TaskThickness.cpp b/src/Mod/Part/Gui/TaskThickness.cpp index d4966790b6..1237ea8b7d 100644 --- a/src/Mod/Part/Gui/TaskThickness.cpp +++ b/src/Mod/Part/Gui/TaskThickness.cpp @@ -24,7 +24,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include # include # include #endif @@ -56,7 +55,6 @@ class ThicknessWidget::Private { public: Ui_TaskOffset ui; - QEventLoop loop; QString text; std::string selection; Part::Thickness* thickness; @@ -126,6 +124,7 @@ ThicknessWidget::ThicknessWidget(Part::Thickness* thickness, QWidget* parent) ThicknessWidget::~ThicknessWidget() { delete d; + Gui::Selection().rmvSelectionGate(); } Part::Thickness* ThicknessWidget::getObject() const @@ -168,9 +167,9 @@ void ThicknessWidget::on_selfIntersection_toggled(bool on) d->thickness->getDocument()->recomputeFeature(d->thickness); } -void ThicknessWidget::on_facesButton_clicked() +void ThicknessWidget::on_facesButton_toggled(bool on) { - if (!d->loop.isRunning()) { + if (on) { QList c = this->findChildren(); for (QList::iterator it = c.begin(); it != c.end(); ++it) (*it)->setEnabled(false); @@ -184,7 +183,6 @@ void ThicknessWidget::on_facesButton_clicked() Gui::Application::Instance->hideViewProvider(d->thickness); Gui::Selection().clearSelection(); Gui::Selection().addSelectionGate(new Private::FaceSelection(d->thickness->Faces.getValue())); - d->loop.exec(); } else { QList c = this->findChildren(); @@ -192,7 +190,6 @@ void ThicknessWidget::on_facesButton_clicked() (*it)->setEnabled(true); d->ui.facesButton->setText(d->text); d->ui.labelFaces->clear(); - d->loop.quit(); d->selection = Gui::Command::getPythonTuple (d->thickness->Faces.getValue()->getNameInDocument(), d->thickness->Faces.getSubValues()); @@ -222,7 +219,7 @@ void ThicknessWidget::on_updateView_toggled(bool on) bool ThicknessWidget::accept() { - if (d->loop.isRunning()) + if (d->ui.facesButton->isChecked()) return false; try { @@ -253,7 +250,7 @@ bool ThicknessWidget::accept() bool ThicknessWidget::reject() { - if (d->loop.isRunning()) + if (d->ui.facesButton->isChecked()) return false; // save this and check if the object is still there after the diff --git a/src/Mod/Part/Gui/TaskThickness.h b/src/Mod/Part/Gui/TaskThickness.h index ab383cfdf7..0a0c57c90c 100644 --- a/src/Mod/Part/Gui/TaskThickness.h +++ b/src/Mod/Part/Gui/TaskThickness.h @@ -48,7 +48,7 @@ private Q_SLOTS: void on_joinType_activated(int); void on_intersection_toggled(bool); void on_selfIntersection_toggled(bool); - void on_facesButton_clicked(); + void on_facesButton_toggled(bool); void on_updateView_toggled(bool); private: