From 0ccb800c019a138d8010a794e8861e7b37339ef8 Mon Sep 17 00:00:00 2001 From: Jason Luckhardt Date: Tue, 8 Apr 2025 17:53:40 -0400 Subject: [PATCH 1/2] Update operate() in Operation.cxx to handle exceptions from operateInternal(). This modification should ensure that a failure outcome is returned, allowing the thread to proceed seamlessly by notifying observers and releasing resources. Consequently, this will enable any threads awaiting resource locks to acquire them and continue their execution without hindrance. --- smtk/operation/Operation.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/smtk/operation/Operation.cxx b/smtk/operation/Operation.cxx index 041cc1261c..caa77fa43d 100644 --- a/smtk/operation/Operation.cxx +++ b/smtk/operation/Operation.cxx @@ -324,8 +324,19 @@ Operation::Result Operation::operate(const BaseKey& key) smtk::attribute::IntItem::Ptr debugItem = this->parameters()->findInt("debug level"); m_debugLevel = ((debugItem && debugItem->isEnabled()) ? debugItem->value() : 0); - // Perform the derived operation. - result = this->operateInternal(); + try + { + // Perform the derived operation. + result = this->operateInternal(); + } + catch (const std::exception&) + { + // Report that the operation failed due to unhandled exception. + // This allows the operation to return normally so that + // any threads do not continue to be blocked. + result = this->createResult(Outcome::FAILED); + } + // Post-process the result if the operation was successful. outcome = static_cast(result->findInt("outcome")->value()); if (outcome == Outcome::SUCCEEDED) -- GitLab From 422d0ed6f78c1348c61f4a578cdd828b201546ab Mon Sep 17 00:00:00 2001 From: Jason Luckhardt Date: Wed, 9 Apr 2025 13:10:56 -0400 Subject: [PATCH 2/2] Addressed comment. --- smtk/operation/Operation.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smtk/operation/Operation.cxx b/smtk/operation/Operation.cxx index caa77fa43d..0f4d6dcb7c 100644 --- a/smtk/operation/Operation.cxx +++ b/smtk/operation/Operation.cxx @@ -329,12 +329,15 @@ Operation::Result Operation::operate(const BaseKey& key) // Perform the derived operation. result = this->operateInternal(); } - catch (const std::exception&) + catch (const std::exception& e) { // Report that the operation failed due to unhandled exception. // This allows the operation to return normally so that // any threads do not continue to be blocked. result = this->createResult(Outcome::FAILED); + smtkErrorMacro( + this->log(), + "An unhandled exception (" << e.what() << ") occurred in " << this->typeName() << "."); } // Post-process the result if the operation was successful. -- GitLab