Skip to content

Commit fcc6726

Browse files
committed
Fix: Avoid overflow
Ensure set_play_state is called even when time_histogram_per_timeline is None. The previous fix incorrectly skipped setting play state flags (playing/following) when no histogram data was available, which could cause incorrect UI state.
1 parent 109b123 commit fcc6726

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

crates/viewer/re_viewer_context/src/time_control.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,23 +529,31 @@ impl TimeControl {
529529

530530
if let Some(new_play_state) = blueprint_ctx.play_state()
531531
&& new_play_state != self.play_state()
532-
&& let Some(time_histogram_per_timeline) = time_histogram_per_timeline
533532
{
534-
self.set_play_state(time_histogram_per_timeline, new_play_state, Some(blueprint_ctx));
533+
if let Some(time_histogram_per_timeline) = time_histogram_per_timeline {
534+
self.set_play_state(time_histogram_per_timeline, new_play_state, Some(blueprint_ctx));
535+
} else {
536+
// Even without histogram data, we need to set the play state flags
537+
let empty_histogram = TimeHistogramPerTimeline::default();
538+
self.set_play_state(&empty_histogram, new_play_state, Some(blueprint_ctx));
539+
}
535540
}
536541

537542
if let Some(new_loop_mode) = blueprint_ctx.loop_mode() {
538543
self.loop_mode = new_loop_mode;
539544

540545
if self.loop_mode != LoopMode::Off {
541-
if self.play_state() == PlayState::Following
542-
&& let Some(time_histogram_per_timeline) = time_histogram_per_timeline
543-
{
544-
self.set_play_state(
545-
time_histogram_per_timeline,
546-
PlayState::Playing,
547-
Some(blueprint_ctx),
548-
);
546+
if self.play_state() == PlayState::Following {
547+
if let Some(time_histogram_per_timeline) = time_histogram_per_timeline {
548+
self.set_play_state(
549+
time_histogram_per_timeline,
550+
PlayState::Playing,
551+
Some(blueprint_ctx),
552+
);
553+
} else {
554+
let empty_histogram = TimeHistogramPerTimeline::default();
555+
self.set_play_state(&empty_histogram, PlayState::Playing, Some(blueprint_ctx));
556+
}
549557
}
550558

551559
// It makes no sense with looping and follow.

0 commit comments

Comments
 (0)