Skip to content

Commit

Permalink
use shared_from_this to avoid crash on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Dorezyuk committed Apr 1, 2020
1 parent a784ac6 commit 73fceed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mbf_costmap_nav/include/mbf_costmap_nav/costmap_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

#include <mbf_utility/types.h>

#include <boost/enable_shared_from_this.hpp>


namespace mbf_costmap_nav
{
Expand All @@ -60,7 +62,7 @@ namespace mbf_costmap_nav
*
* @ingroup navigation_server move_base_server
*/
class CostmapWrapper : public costmap_2d::Costmap2DROS
class CostmapWrapper : public costmap_2d::Costmap2DROS, public boost::enable_shared_from_this<CostmapWrapper>
{
public:
typedef boost::shared_ptr<CostmapWrapper> Ptr;
Expand Down
2 changes: 1 addition & 1 deletion mbf_costmap_nav/src/mbf_costmap_nav/costmap_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void CostmapWrapper::checkDeactivate()
// navigation sequence, what is terribly inefficient; the timer is stopped on costmap re-activation and
// reset after every new call to deactivate
shutdown_costmap_timer_ =
private_nh_.createTimer(shutdown_costmap_delay_, &CostmapWrapper::deactivate, this, true);
private_nh_.createTimer(shutdown_costmap_delay_, &CostmapWrapper::deactivate, shared_from_this(), true);
}
}

Expand Down

0 comments on commit 73fceed

Please sign in to comment.