ros-visualization / rqt_bag

http://wiki.ros.org/rqt_bag
29 stars 53 forks source link

rqt_bag VALUE_ERROR on canceling load prematurely (without selecting a bag to open) #99

Open moslemk opened 3 years ago

moslemk commented 3 years ago

Affected Versions

Latest master, 0.5.1, 0.5.0, and most probably prior versions too

Symptoms

When canceling on loading a bag (i.e., not selecting a bag to load) the code errors out:

Traceback (most recent call last):
  File "/home/moslemk/projects/catkin_ws/src/rqt_bag/rqt_bag/src/rqt_bag/bag_widget.py", line 283, in _handle_load_clicked
    self._timeline._timeline_frame._layout()
  File "/home/moslemk/projects/catkin_ws/src/rqt_bag/rqt_bag/src/rqt_bag/timeline_frame.py", line 392, in _layout
    new_history_bottom = max([y + h for (_, y, _, h) in self._history_bounds.values()]) - 1
ValueError: max() arg is an empty sequence

Root cause

This happens due to trying to get the layout updated with no values due to invalid (none) filename: https://github.com/ros-visualization/rqt_bag/blob/059a2213a0a71d2e07fa6f66e39e0b8da2fa5d75/rqt_bag/src/rqt_bag/bag_widget.py#L279

Possible fix

Checking the filename prior to that line (in `_handle_load_clicked) and returning early.