From 153c7e289d20c3b7bcdfedb13cc06f8aaa5b4fe6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 8 Dec 2023 21:47:03 +0100 Subject: [PATCH] Add explicit API to copy Locations This is in preparation to reduce signals during Location Drag motion (which operates on a copied Location, that causes [static] signal emissions, but the location itself is not in any list). --- libs/ardour/ardour/location.h | 3 ++- libs/ardour/location.cc | 13 +++++++++---- libs/ardour/location_importer.cc | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index 9a1d497567..5d396ca4fa 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -73,7 +73,7 @@ public: Location (Session &); Location (Session &, Temporal::timepos_t const &, Temporal::timepos_t const &, const std::string &, Flags bits = Flags(0), int32_t cue_id = 0); - Location (const Location& other); + Location (Location const& other, bool no_signal); Location (Session &, const XMLNode&); Location* operator= (const Location& other); @@ -207,6 +207,7 @@ protected: void resume_signals (); private: + Location (Location const&); // no copy c'tor void set_mark (bool yn); bool set_flag_internal (bool yn, Flags flag); diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index c10fc816a0..de69980a80 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -91,7 +91,7 @@ Location::Location (Session& s, timepos_t const & start, timepos_t const & end, set_position_time_domain (_session.time_domain()); } -Location::Location (const Location& other) +Location::Location (const Location& other, bool no_emit) : SessionHandleRef (other._session) , _name (other._name) , _start (other._start) @@ -101,8 +101,13 @@ Location::Location (const Location& other) , _cue (other._cue) , _signals_suspended (0) { - /* copy is not locked even if original was */ - assert (other._signals_suspended == 0); + if (no_emit) { + /* use for temp. copies (e.g. during Drag) */ + suspend_signals (); + } else { + /* copy is not locked even if original was */ + assert (other._signals_suspended == 0); + } _locked = false; @@ -1934,7 +1939,7 @@ Locations::cut_copy_section (timepos_t const& start, timepos_t const& end, timep } else if (op == CopyPasteSection) { if (i->start() >= start && i->start() < end) { - Location* copy = new Location (*i); + Location* copy = new Location (*i, false); pastebuf.push_back (copy); } } diff --git a/libs/ardour/location_importer.cc b/libs/ardour/location_importer.cc index 54aa568ef0..414cc201a1 100644 --- a/libs/ardour/location_importer.cc +++ b/libs/ardour/location_importer.cc @@ -135,7 +135,7 @@ LocationImporter::_prepare_move () { try { Location const original (session, xml_location); - location = new Location (original); // Updates id + location = new Location (original, false); // Updates id } catch (failed_constructor& err) { throw std::runtime_error (X_("Error in session file!")); return false;