From 38c69d8da10e79847417cf3726f3aac47addd6b6 Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Mon, 3 Jul 2023 12:23:04 +0200 Subject: [PATCH] FIX: subscribing when manager is unset One feature added to EventManager has been disconnecting a participant at runtime. Unfortunatly, then the manager of this participant is set to nullptr using the setManager method. But this method also subscribes to the shutdown event afterwords. This commit checks if the manager is nullptr and ignore subscribing in that case. --- include/EventManager/Participant.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/EventManager/Participant.hpp b/include/EventManager/Participant.hpp index 0ca39e2..894948c 100644 --- a/include/EventManager/Participant.hpp +++ b/include/EventManager/Participant.hpp @@ -181,7 +181,13 @@ * * @param manager - the manager to set */ - void setManager(std::shared_ptr manager) { manager_=manager;_subscribe(EVENT_TYPE_SHUTDOWN);} + void setManager(std::shared_ptr manager) + { manager_=manager; + if (manager_!=nullptr) + { + _subscribe(EVENT_TYPE_SHUTDOWN); + } + } /** * @brief Method to set the unique id of the participant