fix incorrect locally scoped tempo map management

This is tricky to explain, so rather than explain what was wrong, I'll describe
how it works now.

Whenever a ScopedTempoMapOwner::in() call occurs, we check the current thread-local
tempo map ptr. If it is not owned by us (and we have a local tempo map that we
want to use), set it so that it is.

We continue to fetch() the global tempo map ptr back into the thread-local ptr
when the local scope depth drops to zero.
This commit is contained in:
Paul Davis
2025-10-20 14:58:10 -06:00
parent 297e146152
commit 1114a05f1f

View File

@@ -87,11 +87,17 @@ class LIBTEMPORAL_API ScopedTempoMapOwner
friend struct TempoMapScope;
void in () const {
if (_local_tempo_map && local_tempo_map_depth++ == 0 ) {
DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: in to local tempo %2, TMAP set\n", scope_name(), local_tempo_map_depth));
Temporal::TempoMap::set (_local_tempo_map);
if (_local_tempo_map) {
Temporal::TempoMap::SharedPtr gtmap (Temporal::TempoMap::use());
++local_tempo_map_depth;
if (gtmap->scope_owner() != this) {
DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: in to local tempo %2, TMAP set\n", scope_name(), local_tempo_map_depth));
Temporal::TempoMap::set (_local_tempo_map);
} else {
DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: in to local tempo %s, map left unset\n", scope_name(), local_tempo_map_depth));
}
} else {
DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: in to local tempo %2, no tm set\n", scope_name(), local_tempo_map_depth));
DEBUG_TRACE (PBD::DEBUG::ScopedTempoMap, string_compose ("%1: in to local tempo scope\n", scope_name()));
}
}