[PD] Catch Python exceptions in dtors (Coverity)

In some PartDesign task dialogs, the destructors call functions that may
throw exceptions. If that occurs and the exception is uncaught, this
will ususally end up terminating the program. This commit adds try-catch
blocks around each instance of that (identified by Coverity) and handles
the Python exception in the normal reporting workflow.
This commit is contained in:
Chris Hennes
2021-02-08 13:13:03 -06:00
committed by wwmayer
parent ff85177c3f
commit 40c99417bd
6 changed files with 43 additions and 9 deletions

View File

@@ -309,8 +309,14 @@ bool TaskChamferParameters::getFlipDirection(void) const
TaskChamferParameters::~TaskChamferParameters()
{
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
try {
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
}
catch (const Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
}
bool TaskChamferParameters::event(QEvent *e)

View File

@@ -317,8 +317,14 @@ bool TaskDraftParameters::getReversed(void) const
TaskDraftParameters::~TaskDraftParameters()
{
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
try {
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
}
catch (const Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
}
bool TaskDraftParameters::event(QEvent *e)

View File

@@ -212,8 +212,14 @@ double TaskFilletParameters::getLength(void) const
TaskFilletParameters::~TaskFilletParameters()
{
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
try {
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
}
catch (const Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
}
bool TaskFilletParameters::event(QEvent *e)

View File

@@ -485,7 +485,13 @@ void TaskMultiTransformParameters::apply()
TaskMultiTransformParameters::~TaskMultiTransformParameters()
{
closeSubTask();
try {
closeSubTask();
}
catch (const Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
if (proxy)
delete proxy;
}

View File

@@ -163,6 +163,10 @@ TaskPipeParameters::~TaskPipeParameters()
// getDocument() may raise an exception
e.ReportException();
}
catch (const Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
}
void TaskPipeParameters::updateUI()

View File

@@ -288,8 +288,14 @@ int TaskThicknessParameters::getMode(void) const {
TaskThicknessParameters::~TaskThicknessParameters()
{
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
try {
Gui::Selection().clearSelection();
Gui::Selection().rmvSelectionGate();
}
catch (const Py::Exception&) {
Base::PyException e; // extract the Python error text
e.ReportException();
}
}
bool TaskThicknessParameters::event(QEvent *e)