Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToolManager: shortkey_to_tool_map_ not updated when removing tools #880

Closed
fbacim opened this issue Apr 24, 2015 · 6 comments
Closed

ToolManager: shortkey_to_tool_map_ not updated when removing tools #880

fbacim opened this issue Apr 24, 2015 · 6 comments

Comments

@fbacim
Copy link

fbacim commented Apr 24, 2015

I'm part of a DRC team, and we have our own rviz fork. Since we have our own tools that use librviz, we don't use the tools that are initially inserted when you create a new visualization manager. So, we do

manager_ = new rviz::VisualizationManager( render_panel_ );
manager_->getToolManager()->removeAll();

and then we add our own tools. I have just rebased our fork, and found that the following line caused issues:

https://github.com/ros-visualization/rviz/blame/indigo-devel/src/rviz/tool_manager.cpp#L140

It will insert a new uninitialized Tool* into shortkey_to_tool_map_ if it doesn't have that key in the map already, and causes the application to segfault a few lines after that when trying to set it as the current tool.

I'd suggest changing that line to the following:

Tool* tool = NULL;
  // need to check if it exists in the map, otherwise it will create an uninitialized Tool* with the event->key() inside shortkey_to_tool_map_ and it will segfault later on when trying to access it
  if( shortkey_to_tool_map_.find(event->key()) != shortkey_to_tool_map_.end() )
    tool = shortkey_to_tool_map_[ event->key() ];

Now, that by itself doesn't solve the issue that I'm having: shortkey_to_tool_map_ is never updated outside AddTool. After I remove all tools, shortkey_to_tool_map_ will retain all keys and invalid Tool*, causing it to crash.

@wjwwood
Copy link
Member

wjwwood commented Apr 24, 2015

@hdeeken do you have time to take a look at this issue?

@fbacim I'll have to dig into this to understand what needs to be changed beyond your suggestion, but I can't say right now when that will be. I'll try to work it in opportunistically.

@wjwwood wjwwood added this to the untargeted milestone Apr 24, 2015
@hdeeken
Copy link
Contributor

hdeeken commented Apr 24, 2015

@wjwwood @fbacim RemoveTool obviously needs to alter the map as well. My bad! I'll get to that asap, hopefully within the weekend, otherwise on monday morning. ;)

@wjwwood
Copy link
Member

wjwwood commented Apr 25, 2015

@hdeeken thanks, sorry I missed that in the review on the first go around.

@wjwwood
Copy link
Member

wjwwood commented Aug 5, 2015

Bump, does anyone have time to look into this?

hdeeken added a commit to hdeeken/rviz that referenced this issue Aug 6, 2015
hdeeken added a commit to hdeeken/rviz that referenced this issue Aug 6, 2015
@hdeeken
Copy link
Contributor

hdeeken commented Aug 6, 2015

@wjwwood the above patch should correctly manage the shortkey map now. i'm sorry for fixing this so late, i completely lost track of that! :(

@wjwwood
Copy link
Member

wjwwood commented Aug 7, 2015

@hdeeken that's ok, @fbacim do you have any time to try his patch and see if it addresses the issue for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants