+void
+Session::location_added (Location *location)
+{
+ if (location->is_auto_punch()) {
+ set_auto_punch_location (location);
+ }
+
+ if (location->is_auto_loop()) {
+ set_auto_loop_location (location);
+ }
+
+ if (location->is_session_range()) {
+ /* no need for any signal handling or event setting with the session range,
+ because we keep a direct reference to it and use its start/end directly.
+ */
+ _session_range_location = location;
+ }
+
+ if (location->is_skip()) {
+ /* listen for per-location signals that require us to update skip-locate events */
+
+ location->StartChanged.connect_same_thread (skip_update_connections, boost::bind (&Session::update_skips, this, location, true));
+ location->EndChanged.connect_same_thread (skip_update_connections, boost::bind (&Session::update_skips, this, location, true));
+ location->Changed.connect_same_thread (skip_update_connections, boost::bind (&Session::update_skips, this, location, true));
+ location->FlagsChanged.connect_same_thread (skip_update_connections, boost::bind (&Session::update_skips, this, location, false));
+
+ update_skips (location, true);
+ }
+
+ set_dirty ();
+}
+
+void
+Session::location_removed (Location *location)
+{
+ if (location->is_auto_loop()) {
+ set_auto_loop_location (0);
+ set_track_loop (false);
+ }
+
+ if (location->is_auto_punch()) {
+ set_auto_punch_location (0);
+ }
+
+ if (location->is_session_range()) {
+ /* this is never supposed to happen */
+ error << _("programming error: session range removed!") << endl;
+ }
+
+ if (location->is_skip()) {
+
+ update_skips (location, false);
+ }
+
+ set_dirty ();
+}
+
+void
+Session::locations_changed ()
+{
+ _locations->apply (*this, &Session::_locations_changed);
+}
+
+void
+Session::_locations_changed (const Locations::LocationList& locations)
+{
+ /* There was some mass-change in the Locations object.
+
+ We might be re-adding a location here but it doesn't actually matter
+ for all the locations that the Session takes an interest in.
+ */
+
+ for (Locations::LocationList::const_iterator i = locations.begin(); i != locations.end(); ++i) {
+ location_added (*i);
+ }