[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:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user