From 46a899c437cc5e731cc0648d883a2926bfa7c347 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 9 Feb 2021 11:48:59 -0600 Subject: [PATCH] [Part] Coverity: dtors can't throw --- src/Gui/ViewProviderLink.cpp | 11 ++++++++--- src/Mod/Part/Gui/DlgProjectionOnSurface.cpp | 7 ++++++- src/Mod/Part/Gui/TaskCheckGeometry.cpp | 8 +++++++- src/Mod/Part/Gui/TaskDimension.cpp | 16 ++++++++++++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index fcc875bbe4..2ebc20ec6d 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -2739,9 +2739,14 @@ void ViewProviderLink::dragMotionCallback(void *data, SoDragger *) { } void ViewProviderLink::updateLinks(ViewProvider *vp) { - auto ext = vp->getExtensionByType(true); - if(ext && ext->linkInfo) - ext->linkInfo->update(); + try { + auto ext = vp->getExtensionByType(true); + if (ext && ext->linkInfo) + ext->linkInfo->update(); + } + catch (const Base::TypeError &e) { + e.ReportException(); + } } PyObject *ViewProviderLink::getPyObject() { diff --git a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp index 986014e9f3..afef8676df 100644 --- a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp +++ b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp @@ -178,7 +178,12 @@ DlgProjectionOnSurface::~DlgProjectionOnSurface() delete ui; for ( auto it : m_projectionSurfaceVec) { - higlight_object(it.partFeature, it.partName, false, 0); + try { + higlight_object(it.partFeature, it.partName, false, 0); + } + catch (Standard_NoSuchObject& e) { + Base::Console().Warning("DlgProjectionOnSurface::~DlgProjectionOnSurface: %s", e.GetMessageString()); + } PartGui::ViewProviderPartExt* vp = dynamic_cast(Gui::Application::Instance->getViewProvider(it.partFeature)); if (vp) { diff --git a/src/Mod/Part/Gui/TaskCheckGeometry.cpp b/src/Mod/Part/Gui/TaskCheckGeometry.cpp index f3e44714d3..29fc3b30ed 100644 --- a/src/Mod/Part/Gui/TaskCheckGeometry.cpp +++ b/src/Mod/Part/Gui/TaskCheckGeometry.cpp @@ -393,7 +393,13 @@ TaskCheckGeometryResults::TaskCheckGeometryResults(QWidget *parent) : QWidget(pa TaskCheckGeometryResults::~TaskCheckGeometryResults() { - Gui::Selection().clearSelection(); + try { + Gui::Selection().clearSelection(); + } + catch (const Py::Exception&) { + Base::PyException e; // extract the Python error text + e.ReportException(); + } } void TaskCheckGeometryResults::setupInterface() diff --git a/src/Mod/Part/Gui/TaskDimension.cpp b/src/Mod/Part/Gui/TaskDimension.cpp index 05bdcee265..01dd535909 100644 --- a/src/Mod/Part/Gui/TaskDimension.cpp +++ b/src/Mod/Part/Gui/TaskDimension.cpp @@ -522,7 +522,13 @@ PartGui::TaskMeasureLinear::TaskMeasureLinear() PartGui::TaskMeasureLinear::~TaskMeasureLinear() { - Gui::Selection().clearSelection(); + try { + Gui::Selection().clearSelection(); + } + catch (const Py::Exception&) { + Base::PyException e; // extract the Python error text + e.ReportException(); + } } void PartGui::TaskMeasureLinear::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -1513,7 +1519,13 @@ PartGui::TaskMeasureAngular::TaskMeasureAngular() PartGui::TaskMeasureAngular::~TaskMeasureAngular() { - Gui::Selection().clearSelection(); + try { + Gui::Selection().clearSelection(); + } + catch (const Py::Exception&) { + Base::PyException e; // extract the Python error text + e.ReportException(); + } } void PartGui::TaskMeasureAngular::onSelectionChanged(const Gui::SelectionChanges& msg)