diff --git a/doc/release/notes/task-active-notification.rst b/doc/release/notes/task-active-notification.rst new file mode 100644 index 0000000000000000000000000000000000000000..8ff1f8ed53ad34bf74e1f4c8e1fc0e64a8709232 --- /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/graph/Component.h b/smtk/graph/Component.h index 63bdc3cb6c654a3d08be1f8dd5e7982e2bb620b5..3d57e7b37f59088a32485a204b89eabec68726d9 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."); } diff --git a/smtk/task/Active.cxx b/smtk/task/Active.cxx index 9c7ac8e65127f23379c7c48e2bd3e94ece494b19..947e156392d853048249065c4cc8059e9a026ec5 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) {