Further consolidate locations signal emissions

This commit is contained in:
Robin Gareus 2023-12-10 04:10:45 +01:00
parent fa0d1d98f9
commit f191d8ba94
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -1277,6 +1277,8 @@ Locations::set_state (const XMLNode& node, int version)
/* build up a new locations list in here */ /* build up a new locations list in here */
LocationList new_locations; LocationList new_locations;
bool emit_changed = false;
{ {
std::vector<Location::ChangeSuspender> lcs; std::vector<Location::ChangeSuspender> lcs;
Glib::Threads::RWLock::WriterLock lm (_lock); Glib::Threads::RWLock::WriterLock lm (_lock);
@ -1313,6 +1315,7 @@ Locations::set_state (const XMLNode& node, int version)
loc = new Location (_session); loc = new Location (_session);
lcs.emplace_back (std::move (loc)); lcs.emplace_back (std::move (loc));
loc->set_state (**niter, version); loc->set_state (**niter, version);
emit_changed = true;
} }
bool add = true; bool add = true;
@ -1373,6 +1376,7 @@ Locations::set_state (const XMLNode& node, int version)
if (!found) { if (!found) {
delete *i; delete *i;
locations.erase (i); locations.erase (i);
emit_changed = true;
} }
i = tmp; i = tmp;
@ -1387,7 +1391,9 @@ Locations::set_state (const XMLNode& node, int version)
} }
} }
changed (); /* EMIT SIGNAL */ if (emit_changed) {
changed (); /* EMIT SIGNAL */
}
return 0; return 0;
} }
@ -1816,12 +1822,14 @@ Locations::ripple (timepos_t const & at, timecnt_t const & distance, bool includ
copy = locations; copy = locations;
} }
std::vector<Location::ChangeSuspender> lcs;
for (LocationList::iterator i = copy.begin(); i != copy.end(); ++i) { for (LocationList::iterator i = copy.begin(); i != copy.end(); ++i) {
if ( (*i)->is_session_range() || (*i)->is_auto_punch() || (*i)->is_auto_loop() ) { if ( (*i)->is_session_range() || (*i)->is_auto_punch() || (*i)->is_auto_loop() ) {
continue; continue;
} }
lcs.emplace_back (std::move (*i));
bool locked = (*i)->locked(); bool locked = (*i)->locked();
if (locked) { if (locked) {