diff --git a/src/problem/problem.cpp b/src/problem/problem.cpp index ec8db837c547efaf489ea846454bda830f6abe59..056db02dc4c5022e4bfb0b4d505c7533f71571da 100644 --- a/src/problem/problem.cpp +++ b/src/problem/problem.cpp @@ -440,11 +440,19 @@ StateBlockPtr Problem::notifyStateBlock(StateBlockPtr _state_ptr, Notification _ // Check if there is already a notification for this state block auto notification_it = state_block_notification_map_.find(_state_ptr); - if (notification_it != state_block_notification_map_.end() && notification_it->second == _noti) + // exsiting notification for this state block + if (notification_it != state_block_notification_map_.end()) { - WOLF_WARN("This notification has been already notified"); + // duplicated notification + if ( notification_it->second == _noti) + { + WOLF_WARN("This notification has been already notified"); + } + // opposite notification -> cancell out eachother + else + state_block_notification_map_.erase(notification_it); } - // Add notification (override in case of different existing ADD overwrites REMOVE or viceversa) + // Add notification else state_block_notification_map_[_state_ptr] = _noti; @@ -468,11 +476,20 @@ FactorBasePtr Problem::notifyFactor(FactorBasePtr _factor_ptr, Notification _not // Check if there is already the same notification for this factor auto notification_it = factor_notification_map_.find(_factor_ptr); - if (notification_it != factor_notification_map_.end() && notification_it->second == _noti) + // exsiting notification for this factor + if (notification_it != factor_notification_map_.end()) { - WOLF_WARN("This notification has been already notified"); + // duplicated notification + if (notification_it->second == _noti) + { + WOLF_WARN("This notification has been already notified"); + } + // opposite notification -> cancell out eachother + else + factor_notification_map_.erase(notification_it); + } - // Add notification (override in case of different existing ADD overwrites REMOVE or viceversa) + // Add notification else factor_notification_map_[_factor_ptr] = _noti;