Part: do not use local event loop in sweep and thickness panel

This commit is contained in:
wmayer
2020-09-16 12:14:04 +02:00
parent 5abb45f7cf
commit be22fb0bc5
6 changed files with 18 additions and 18 deletions

View File

@@ -113,6 +113,9 @@
<property name="text">
<string>Faces</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2">

View File

@@ -25,7 +25,6 @@
#ifndef _PreComp_
# include <QApplication>
# include <QEventLoop>
# include <QMessageBox>
# include <QTextStream>
# include <QTimer>
@@ -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<QWidget*> c = this->findChildren<QWidget*>();
for (QList<QWidget*>::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<QWidget*> c = this->findChildren<QWidget*>();
@@ -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");

View File

@@ -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);

View File

@@ -22,6 +22,9 @@
<property name="text">
<string>Sweep Path</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">

View File

@@ -24,7 +24,6 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QEventLoop>
# include <QMessageBox>
# include <QTextStream>
#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<QWidget*> c = this->findChildren<QWidget*>();
for (QList<QWidget*>::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<QWidget*> c = this->findChildren<QWidget*>();
@@ -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

View File

@@ -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: