Skip to content

Commit

Permalink
Sentry fix: protect against missing timeline object (likely during sh…
Browse files Browse the repository at this point in the history
…utdown)
  • Loading branch information
jonoomph committed Dec 6, 2022
1 parent c31219d commit 5957c1b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,11 +973,13 @@ def should_play(self, requested_speed=0):
if we are at the end of our last clip, and the user clicks play, we
do not want to start playback."""
# Get max frame (based on last clip) and current frame
max_frame = get_app().window.timeline_sync.timeline.GetMaxFrame()
current_frame = self.preview_thread.current_frame
if current_frame is not None:
next_frame = current_frame + requested_speed
return next_frame <= max_frame and next_frame > 0
timeline_sync = get_app().window.timeline_sync
if timeline_sync and timeline_sync.timeline:
max_frame = timeline_sync.timeline.GetMaxFrame()
current_frame = self.preview_thread.current_frame
if current_frame is not None:
next_frame = current_frame + requested_speed
return next_frame <= max_frame and next_frame > 0
return False

def actionPlay_trigger(self):
Expand All @@ -986,7 +988,6 @@ def actionPlay_trigger(self):
if player.Mode() == openshot.PLAYBACK_PAUSED:
# Start playback
if self.should_play():
max_frame = get_app().window.timeline_sync.timeline.GetMaxFrame()
self.PlaySignal.emit()
else:
# Pause playback
Expand Down

0 comments on commit 5957c1b

Please sign in to comment.