Skip to content

Commit b7fa6c7

Browse files
markreidvfxMichaelPlug
authored andcommitted
Prevent divide by zero and print warning if width is zero (AcademySoftwareFoundation#1346)
Signed-off-by: Mark Reid <[email protected]> Signed-off-by: Michele Spina <[email protected]>
1 parent 019635d commit b7fa6c7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/opentimelineview/ruler_widget.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,15 @@ def map_to_time_space(self, item):
174174
is_head = False
175175
is_tail = False
176176
f = "-?-"
177+
ratio = -1.0
178+
width = float(item.rect().width())
177179

178-
ratio = (self.x() - item.x() +
179-
track_widgets.CURRENT_ZOOM_LEVEL *
180-
track_widgets.TRACK_NAME_WIDGET_WIDTH) / float(item.rect().width())
180+
if width > 0.0:
181+
ratio = (self.x() - item.x() +
182+
track_widgets.CURRENT_ZOOM_LEVEL *
183+
track_widgets.TRACK_NAME_WIDGET_WIDTH) / width
184+
else:
185+
print("Warning: zero width item: {}.".format(item))
181186

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

0 commit comments

Comments
 (0)