diff --git a/common/src/environment_wrapper.cpp b/common/src/environment_wrapper.cpp index c6ee72d0..12fa1de0 100644 --- a/common/src/environment_wrapper.cpp +++ b/common/src/environment_wrapper.cpp @@ -358,7 +358,11 @@ DefaultEnvironmentWrapper::DefaultEnvironmentWrapper(ComponentInfo component_inf qGuiApp->installEventFilter(this); } -DefaultEnvironmentWrapper::~DefaultEnvironmentWrapper() = default; +DefaultEnvironmentWrapper::~DefaultEnvironmentWrapper() +{ + if (initialized_ && env_) + env_->removeEventCallback(std::hash()(this)); +} std::shared_ptr DefaultEnvironmentWrapper::getEnvironment() const { @@ -389,7 +393,12 @@ MonitorEnvironmentWrapper::MonitorEnvironmentWrapper( // Install event filter for interactive view controller qGuiApp->installEventFilter(this); } -MonitorEnvironmentWrapper::~MonitorEnvironmentWrapper() = default; + +MonitorEnvironmentWrapper::~MonitorEnvironmentWrapper() +{ + if (initialized_ && env_monitor_) + environment().removeEventCallback(std::hash()(this)); +} std::shared_ptr MonitorEnvironmentWrapper::getEnvironment() const { diff --git a/joint_trajectory/src/models/joint_trajectory_model.cpp b/joint_trajectory/src/models/joint_trajectory_model.cpp index f5d1f66a..2587f978 100644 --- a/joint_trajectory/src/models/joint_trajectory_model.cpp +++ b/joint_trajectory/src/models/joint_trajectory_model.cpp @@ -81,7 +81,7 @@ void JointTrajectoryModel::addJointTrajectorySet(tesseract_common::JointTrajecto if (env_wrapper != nullptr) { auto env = env_wrapper->getEnvironment(); - if (env != nullptr || env->isInitialized()) + if (env != nullptr && env->isInitialized()) trajectory_set.applyEnvironment(env->clone()); } else @@ -90,7 +90,7 @@ void JointTrajectoryModel::addJointTrajectorySet(tesseract_common::JointTrajecto if (env_wrapper != nullptr) { auto env = env_wrapper->getEnvironment(); - if (env != nullptr || env->isInitialized()) + if (env != nullptr && env->isInitialized()) trajectory_set.applyEnvironment(env->clone()); } }