Skip to content

Commit

Permalink
Prevent divide by zero and print warning if width is zero (AcademySof…
Browse files Browse the repository at this point in the history
…twareFoundation#1346)

Signed-off-by: Mark Reid <[email protected]>
Signed-off-by: Michele Spina <[email protected]>
  • Loading branch information
markreidvfx authored and MichaelPlug committed Aug 5, 2023
1 parent 019635d commit b7fa6c7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/opentimelineview/ruler_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,15 @@ def map_to_time_space(self, item):
is_head = False
is_tail = False
f = "-?-"
ratio = -1.0
width = float(item.rect().width())

ratio = (self.x() - item.x() +
track_widgets.CURRENT_ZOOM_LEVEL *
track_widgets.TRACK_NAME_WIDGET_WIDTH) / float(item.rect().width())
if width > 0.0:
ratio = (self.x() - item.x() +
track_widgets.CURRENT_ZOOM_LEVEL *
track_widgets.TRACK_NAME_WIDGET_WIDTH) / width
else:
print("Warning: zero width item: {}.".format(item))

# The 'if' condition should be : ratio < 0 or ration >= 1
# However, we are cheating in order to display the last frame of
Expand Down

0 comments on commit b7fa6c7

Please sign in to comment.