From a10ce56c2cdb72170af88b7beb77a867c2aab10f Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 15 Mar 2025 09:37:39 -0400 Subject: [PATCH 1/2] Change the active task before observers are notified. --- doc/release/notes/task-active-notification.rst | 10 ++++++++++ smtk/task/Active.cxx | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 doc/release/notes/task-active-notification.rst diff --git a/doc/release/notes/task-active-notification.rst b/doc/release/notes/task-active-notification.rst new file mode 100644 index 0000000000..8ff1f8ed53 --- /dev/null +++ b/doc/release/notes/task-active-notification.rst @@ -0,0 +1,10 @@ +Task System +=========== + +Active task notifications +------------------------- + +Observers of the :smtk:`smtk::task::Active` are now invoked after +(rather than before) the active task has been changed. +This means that responders can fetch the active task inside the +observer and it will match the "next" task rather than the current task. diff --git a/smtk/task/Active.cxx b/smtk/task/Active.cxx index 9c7ac8e651..947e156392 100644 --- a/smtk/task/Active.cxx +++ b/smtk/task/Active.cxx @@ -82,9 +82,9 @@ bool Active::switchTo(smtk::task::Task* task) { if (current) { - m_p->m_observers(current.get(), nullptr); m_p->m_active.reset(); m_p->m_activeObserver.release(); + m_p->m_observers(current.get(), nullptr); return true; } return false; @@ -99,8 +99,8 @@ bool Active::switchTo(smtk::task::Task* task) // Only managed tasks can be active if we have instances tracked. return false; } - m_p->m_observers(current.get(), task); m_p->m_active = sharedTask; + m_p->m_observers(current.get(), task); m_p->m_activeObserver = task->observers().insert([this](Task&, State, State next) { if (next == State::Unavailable) { -- GitLab From 44576977bf839487d2be90f7666fbc0550033775 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 15 Mar 2025 10:28:32 -0400 Subject: [PATCH 2/2] Fix ubsan warnings. --- smtk/graph/Component.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/smtk/graph/Component.h b/smtk/graph/Component.h index 63bdc3cb6c..3d57e7b37f 100644 --- a/smtk/graph/Component.h +++ b/smtk/graph/Component.h @@ -121,9 +121,8 @@ public: else { std::ostringstream msg; - msg << "This component is not the proper type (" << this->typeName() - << ") for the arc's endpoint (" << smtk::common::typeName() - << ")."; + msg << "This component is not the proper type for the " + << "arc's endpoint (" << smtk::common::typeName() << ")."; throw std::logic_error( msg.str()); // "This component is not the proper type for the arc's endpoint."); } @@ -156,9 +155,8 @@ public: else { std::ostringstream msg; - msg << "This component is not the proper type (" << this->typeName() - << ") for the arc's endpoint (" << smtk::common::typeName() - << ")."; + msg << "This component is not the proper type for the " + << "arc's endpoint (" << smtk::common::typeName() << ")."; throw std::logic_error( msg.str()); // "This component is not the proper type for the arc's endpoint."); } @@ -203,9 +201,8 @@ public: else { std::ostringstream msg; - msg << "This component is not the proper type (" << this->typeName() - << ") for the arc's endpoint (" << smtk::common::typeName() - << ")."; + msg << "This component is not the proper type for the " + << "arc's endpoint (" << smtk::common::typeName() << ")."; throw std::logic_error( msg.str()); // "This component is not the proper type for the arc's endpoint."); } @@ -239,9 +236,8 @@ public: else { std::ostringstream msg; - msg << "This component is not the proper type (" << this->typeName() - << ") for the arc's endpoint (" << smtk::common::typeName() - << ")."; + msg << "This component is not the proper type for the " + << "arc's endpoint (" << smtk::common::typeName() << ")."; throw std::logic_error( msg.str()); // "This component is not the proper type for the arc's endpoint."); } -- GitLab