From ccbbe3d7088c956434b30b3fbb9d2ca8048406bc Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sun, 23 Mar 2025 13:25:09 -0500 Subject: [PATCH] Fem: catch exceptions in destructor --- src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp index ef40748888..7d8d048585 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp @@ -261,27 +261,40 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() ViewProviderFemPostObject::~ViewProviderFemPostObject() { - FemPostObjectSelectionObserver::instance().unregisterFemPostObject(this); - m_transpType->unref(); - m_depthBuffer->unref(); - m_shapeHints->unref(); - m_coordinates->unref(); - m_materialBinding->unref(); - m_drawStyle->unref(); - m_normalBinding->unref(); - m_normals->unref(); - m_faces->unref(); - m_triangleStrips->unref(); - m_markers->unref(); - m_lines->unref(); - m_sepMarkerLine->unref(); - m_separator->unref(); - m_material->unref(); - m_matPlainEdges->unref(); - m_switchMatEdges->unref(); - deleteColorBar(); - m_colorStyle->unref(); - m_colorRoot->unref(); + try { + FemPostObjectSelectionObserver::instance().unregisterFemPostObject(this); + m_transpType->unref(); + m_depthBuffer->unref(); + m_shapeHints->unref(); + m_coordinates->unref(); + m_materialBinding->unref(); + m_drawStyle->unref(); + m_normalBinding->unref(); + m_normals->unref(); + m_faces->unref(); + m_triangleStrips->unref(); + m_markers->unref(); + m_lines->unref(); + m_sepMarkerLine->unref(); + m_separator->unref(); + m_material->unref(); + m_matPlainEdges->unref(); + m_switchMatEdges->unref(); + m_colorStyle->unref(); + m_colorRoot->unref(); + deleteColorBar(); + } + catch (Base::Exception& e) { + Base::Console().DestructorError( + "ViewProviderFemPostObject", + "ViewProviderFemPostObject destructor threw an exception: %s\n", + e.what()); + } + catch (...) { + Base::Console().DestructorError( + "ViewProviderFemPostObject", + "ViewProviderFemPostObject destructor threw an unknown exception"); + } } void ViewProviderFemPostObject::deleteColorBar()