void Layout::add(Object &o)
{
if(objects.insert(o))
- signal_object_added.emit(o);
+ {
+ try
+ {
+ signal_object_added.emit(o);
+ }
+ catch(...)
+ {
+ objects.erase(o);
+ throw;
+ }
+ }
}
void Layout::add(Track &t)
{
if(objects.insert(t))
{
- // Blocks must be recreated first
- create_blocks();
- signal_object_added.emit(t);
+ try
+ {
+ // Blocks must be recreated first
+ create_blocks();
+ signal_object_added.emit(t);
+ }
+ catch(...)
+ {
+ objects.erase(t);
+ create_blocks();
+ throw;
+ }
}
}
void Layout::add(TrackChain &g)
{
if(track_chains.insert(g))
- signal_track_chain_added.emit(g);
+ {
+ try
+ {
+ signal_track_chain_added.emit(g);
+ }
+ catch(...)
+ {
+ track_chains.erase(g);
+ throw;
+ }
+ }
}
void Layout::add(Block &b)
{
if(track_chains.insert(b))
{
- b.signal_reserved.connect(sigc::bind<0>(signal_block_reserved, sigc::ref(b)));
- signal_track_chain_added.emit(b);
+ sigc::connection conn = b.signal_reserved.connect(sigc::bind<0>(signal_block_reserved, sigc::ref(b)));
+ try
+ {
+ signal_track_chain_added.emit(b);
+ }
+ catch(...)
+ {
+ track_chains.erase(b);
+ conn.disconnect();
+ throw;
+ }
}
}