#include <inttypes.h>
#include "pbd/error.h"
-#include "pbd/boost_debug.h"
-#include "ardour/session.h"
-
-#include "ardour/region_factory.h"
-#include "ardour/region.h"
#include "ardour/audioregion.h"
#include "ardour/audiosource.h"
-#include "ardour/midi_source.h"
#include "ardour/midi_region.h"
-#include "ardour/utils.h"
+#include "ardour/midi_source.h"
+#include "ardour/region.h"
+#include "ardour/region_factory.h"
+#include "ardour/session.h"
#include "i18n.h"
PBD::Signal1<void,boost::shared_ptr<Region> > RegionFactory::CheckNewRegion;
Glib::StaticMutex RegionFactory::region_map_lock;
RegionFactory::RegionMap RegionFactory::region_map;
-PBD::ScopedConnectionList RegionFactory::region_list_connections;
+PBD::ScopedConnectionList* RegionFactory::region_list_connections = 0;
Glib::StaticMutex RegionFactory::region_name_map_lock;
std::map<std::string, uint32_t> RegionFactory::region_name_map;
RegionFactory::CompoundAssociations RegionFactory::_compound_associations;
if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) {
ret->set_position_lock_style (MusicTime);
}
-
- map_add (ret);
/* pure copy constructor - no property list */
if (announce) {
+ map_add (ret);
CheckNewRegion (ret);
}
}
ret->set_position_lock_style (MusicTime);
}
- map_add (ret);
-
if (announce) {
+ map_add (ret);
CheckNewRegion (ret);
}
}
ret->set_position_lock_style (MusicTime);
}
- map_add (ret);
-
if (announce) {
+ map_add (ret);
CheckNewRegion (ret);
}
}
ret->set_position_lock_style (MusicTime);
}
- map_add (ret);
-
if (announce) {
+ map_add (ret);
CheckNewRegion (ret);
}
}
ret->set_position_lock_style (MusicTime);
}
- map_add (ret);
-
if (announce) {
+ map_add (ret);
CheckNewRegion (ret);
}
}
region_map.insert (p);
}
- r->DropReferences.connect_same_thread (region_list_connections, boost::bind (&RegionFactory::map_remove, r));
+ if (!region_list_connections) {
+ region_list_connections = new ScopedConnectionList;
+ }
- r->PropertyChanged.connect_same_thread (
- region_list_connections,
- boost::bind (&RegionFactory::region_changed, _1, boost::weak_ptr<Region> (r))
- );
+ r->DropReferences.connect_same_thread (*region_list_connections, boost::bind (&RegionFactory::map_remove, boost::weak_ptr<Region> (r)));
+ r->PropertyChanged.connect_same_thread (*region_list_connections, boost::bind (&RegionFactory::region_changed, _1, boost::weak_ptr<Region> (r)));
update_region_name_map (r);
}
void
-RegionFactory::map_remove (boost::shared_ptr<Region> r)
+RegionFactory::map_remove (boost::weak_ptr<Region> w)
{
+ boost::shared_ptr<Region> r = w.lock ();
+ if (!r) {
+ return;
+ }
+
Glib::Mutex::Lock lm (region_map_lock);
RegionMap::iterator i = region_map.find (r->id());
}
}
-void
-RegionFactory::map_remove_with_equivalents (boost::shared_ptr<Region> r)
-{
- Glib::Mutex::Lock lm (region_map_lock);
-
- for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ) {
- RegionMap::iterator tmp = i;
- ++tmp;
-
- if (r->region_list_equivalent (i->second)) {
- region_map.erase (i);
- } else if (r == i->second) {
- region_map.erase (i);
- }
-
- i = tmp;
- }
-}
-
boost::shared_ptr<Region>
RegionFactory::region_by_id (const PBD::ID& id)
{
void
RegionFactory::clear_map ()
{
- region_list_connections.drop_connections ();
+ if (region_list_connections) {
+ region_list_connections->drop_connections ();
+ }
{
Glib::Mutex::Lock lm (region_map_lock);