From dd41fddcadc27cc16858c7eb4c521cccd60835d2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 11 Aug 2025 15:41:03 -0600 Subject: [PATCH] temporal: fix up some logic relating to scoped tempo maps --- libs/temporal/tempo.cc | 6 ++++++ libs/temporal/temporal/scope.h | 12 ++++++++---- libs/temporal/temporal/tempo.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 8d9a10d1f6..01d73d9aee 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -859,6 +859,12 @@ TempoMap::set_scope_owner (ScopedTempoMapOwner& sco) _scope_owner = &sco; } +void +TempoMap::clear_scope_owner () +{ + _scope_owner = nullptr; +} + TempoMap& TempoMap::operator= (TempoMap const & other) { diff --git a/libs/temporal/temporal/scope.h b/libs/temporal/temporal/scope.h index 71d2170ed9..cf34ee6dee 100644 --- a/libs/temporal/temporal/scope.h +++ b/libs/temporal/temporal/scope.h @@ -35,16 +35,20 @@ class ScopedTempoMapOwner virtual ~ScopedTempoMapOwner () {} void start_local_tempo_map (std::shared_ptr map) { - _local_tempo_map = map; - in (); DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: starting local tempo scope\n", scope_name())); + map->set_scope_owner (*this); + _local_tempo_map = map; + Temporal::TempoMap::set (_local_tempo_map); + local_tempo_map_depth = 1; } void end_local_tempo_map () { DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: ending local tempo scope\n", scope_name())); - local_tempo_map_depth = 1; /* force exit in out() */ - out (); + assert (_local_tempo_map); + local_tempo_map_depth = 0; + _local_tempo_map->clear_scope_owner (); _local_tempo_map.reset (); + Temporal::TempoMap::fetch (); } uint64_t depth() const { return local_tempo_map_depth; } diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 46df36679f..9caff963d3 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -1011,6 +1011,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible static void map_assert (bool expr, char const * exprstr, char const * file, int line); void set_scope_owner (ScopedTempoMapOwner&); + void clear_scope_owner (); ScopedTempoMapOwner* scope_owner() const { return _scope_owner; } private: