Skip to content

Commit 058b0df

Browse files
committed
Fix some TODOs
1 parent b576282 commit 058b0df

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

crates/store/re_log_types/src/index/time_point.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ impl TimePoint {
5252
}
5353
}
5454

55-
// #[deprecated] // TODO
5655
#[inline]
5756
pub fn insert(&mut self, timeline: Timeline, time: impl TryInto<TimeInt>) {
5857
let cell = IndexCell::new(
@@ -73,7 +72,6 @@ impl TimePoint {
7372
self
7473
}
7574

76-
// #[deprecated] // TODO
7775
#[must_use]
7876
#[inline]
7977
pub fn with(mut self, timeline: Timeline, time: impl TryInto<TimeInt>) -> Self {

crates/top/re_sdk/src/recording_stream.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,9 +2117,32 @@ impl RecordingStream {
21172117
/// - [`Self::disable_timeline`]
21182118
/// - [`Self::reset_time`]
21192119
pub fn set_time_seconds(&self, timeline: impl Into<TimelineName>, seconds: impl Into<f64>) {
2120-
let seconds = seconds.into();
2121-
// TODO: clamp with warning
2122-
self.set_time_nanos(timeline, (1e9 * seconds).round() as i64);
2120+
let f = move |inner: &RecordingStreamInner| {
2121+
let mut seconds = seconds.into();
2122+
if seconds.is_nan() {
2123+
re_log::error!("set_time_seconds() called with NaN");
2124+
seconds = 0.0;
2125+
}
2126+
2127+
let nanos = 1e9 * seconds;
2128+
let nanos_clamped = nanos.clamp(NonMinI64::MIN.get() as _, NonMinI64::MAX.get() as _);
2129+
2130+
if nanos != nanos_clamped {
2131+
re_log::warn_once!(
2132+
"set_time_seconds() called with out-of-range value {seconds:?}. Clamping to valid range."
2133+
);
2134+
}
2135+
2136+
ThreadInfo::set_thread_time(
2137+
&inner.info.store_id,
2138+
timeline.into(),
2139+
IndexCell::from_duration_nanos(nanos_clamped.round() as i64),
2140+
);
2141+
};
2142+
2143+
if self.with(f).is_none() {
2144+
re_log::warn_once!("Recording disabled - call to set_time_seconds() ignored");
2145+
}
21232146
}
21242147

21252148
/// Set the current time of the recording, for the current calling thread.

0 commit comments

Comments
 (0)