From 8ec81c23088ebdb9e9df1d6a9c6fe216bc9b8f35 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 4 Aug 2020 17:41:11 -0600 Subject: [PATCH] Temporal: correctly construct return timepos_t for * and / --- libs/temporal/temporal/timeline.h | 4 ++++ libs/temporal/timeline.cc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/temporal/temporal/timeline.h b/libs/temporal/temporal/timeline.h index b4a985e4d9..6736f241be 100644 --- a/libs/temporal/temporal/timeline.h +++ b/libs/temporal/temporal/timeline.h @@ -198,6 +198,10 @@ class timepos_t : public int62_t { private: int64_t v; + /* special private constructor for use when constructing timepos_t as a + return value using arithmetic ops + */ + explicit timepos_t (bool b, int64_t v) : int62_t (b, v) {} static timepos_t _max_timepos; diff --git a/libs/temporal/timeline.cc b/libs/temporal/timeline.cc index f013739f77..b3e8dc0b97 100644 --- a/libs/temporal/timeline.cc +++ b/libs/temporal/timeline.cc @@ -264,14 +264,14 @@ timepos_t::operator/(ratio_t const & n) const /* note: v / (N/D) = (v * D) / N */ - return timepos_t (int_div_round (val() * n.denominator(), n.numerator())); + return timepos_t (is_beats(), int_div_round (val() * n.denominator(), n.numerator())); } timepos_t timepos_t::operator*(ratio_t const & n) const { assert (n >= 0); /* do not allow a position to become negative via multiplication */ - return timepos_t (int_div_round (val() * n.numerator(), n.denominator())); + return timepos_t (is_beats(), int_div_round (val() * n.numerator(), n.denominator())); } timepos_t &