revert VST debug hacks
[ardour.git] / libs / ardour / region.cc
index e8353ac52909ffa41edd77aee266175a47803d9b..9d81cc5907830a24c5b76549f8bd49a8e5808e57 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <glibmm/thread.h>
 #include <pbd/xml++.h>
+#include <pbd/stacktrace.h>
 
 #include <ardour/region.h>
 #include <ardour/playlist.h>
@@ -48,12 +49,11 @@ Change Region::LockChanged       = ARDOUR::new_change ();
 Change Region::LayerChanged      = ARDOUR::new_change ();
 Change Region::HiddenChanged     = ARDOUR::new_change ();
 
-Region::Region (jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Region::Flag flags)
+Region::Region (nframes_t start, nframes_t length, const string& name, layer_t layer, Region::Flag flags)
 {
        /* basic Region constructor */
 
        _flags = flags;
-       _playlist = 0;
        _read_data_count = 0;
        _frozen = 0;
        pending_changed = Change (0);
@@ -64,19 +64,17 @@ Region::Region (jack_nframes_t start, jack_nframes_t length, const string& name,
        _length = length; 
        _position = 0; 
        _layer = layer;
-       _current_state_id = 0;
        _read_data_count = 0;
        _first_edit = EditChangesNothing;
        _last_layer_op = 0;
 }
 
-Region::Region (boost::shared_ptr<const Region> other, jack_nframes_t offset, jack_nframes_t length, const string& name, layer_t layer, Flag flags)
+Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
 {
        /* create a new Region from part of an existing one */
 
        _frozen = 0;
        pending_changed = Change (0);
-       _playlist = 0;
        _read_data_count = 0;
 
        _start = other->_start + offset; 
@@ -90,7 +88,6 @@ Region::Region (boost::shared_ptr<const Region> other, jack_nframes_t offset, ja
        _position = 0; 
        _layer = layer; 
        _flags = Flag (flags & ~(Locked|WholeFile|Hidden));
-       _current_state_id = 0;
        _first_edit = EditChangesNothing;
        _last_layer_op = 0;
 }
@@ -101,7 +98,6 @@ Region::Region (boost::shared_ptr<const Region> other)
 
        _frozen = 0;
        pending_changed = Change (0);
-       _playlist = 0;
        _read_data_count = 0;
 
        _first_edit = EditChangesID;
@@ -120,7 +116,6 @@ Region::Region (boost::shared_ptr<const Region> other)
        _position = other->_position; 
        _layer = other->_layer; 
        _flags = Flag (other->_flags & ~Locked);
-       _current_state_id = 0;
        _last_layer_op = other->_last_layer_op;
 }
 
@@ -128,7 +123,6 @@ Region::Region (const XMLNode& node)
 {
        _frozen = 0;
        pending_changed = Change (0);
-       _playlist = 0;
        _read_data_count = 0;
        _start = 0; 
        _sync_position = _start;
@@ -137,7 +131,6 @@ Region::Region (const XMLNode& node)
        _position = 0; 
        _layer = 0;
        _flags = Flag (0);
-       _current_state_id = 0;
        _first_edit = EditChangesNothing;
 
        if (set_state (node)) {
@@ -147,81 +140,17 @@ Region::Region (const XMLNode& node)
 
 Region::~Region ()
 {
-       notify_callbacks ();
-
-       /* derived classes must emit GoingAway */
+       /* derived classes must call notify_callbacks() and then emit GoingAway */
 }
 
 void
-Region::set_playlist (Playlist* pl)
+Region::set_playlist (boost::weak_ptr<Playlist> pl)
 {
        _playlist = pl;
 }
 
-void
-Region::store_state (RegionState& state) const
-{
-       state._start = _start;
-       state._length = _length;
-       state._position = _position;
-       state._flags = _flags;
-       state._sync_position = _sync_position;
-       state._layer = _layer;
-       state._name = _name;
-       state._first_edit = _first_edit;
-}      
-
-Change
-Region::restore_and_return_flags (RegionState& state)
-{
-       Change what_changed = Change (0);
-
-       {
-               Glib::Mutex::Lock lm (lock);
-               
-               if (_start != state._start) {
-                       what_changed = Change (what_changed|StartChanged);      
-                       _start = state._start;
-               }
-               if (_length != state._length) {
-                       what_changed = Change (what_changed|LengthChanged);
-                       _length = state._length;
-               }
-               if (_position != state._position) {
-                       what_changed = Change (what_changed|PositionChanged);
-                       _position = state._position;
-               } 
-               if (_sync_position != state._sync_position) {
-                       _sync_position = state._sync_position;
-                       what_changed = Change (what_changed|SyncOffsetChanged);
-               }
-               if (_layer != state._layer) {
-                       what_changed = Change (what_changed|LayerChanged);
-                       _layer = state._layer;
-               }
-
-               uint32_t old_flags = _flags;
-               _flags = Flag (state._flags);
-               
-               if ((old_flags ^ state._flags) & Muted) {
-                       what_changed = Change (what_changed|MuteChanged);
-               }
-               if ((old_flags ^ state._flags) & Opaque) {
-                       what_changed = Change (what_changed|OpacityChanged);
-               }
-               if ((old_flags ^ state._flags) & Locked) {
-                       what_changed = Change (what_changed|LockChanged);
-               }
-
-               _first_edit = state._first_edit;
-       }
-
-       return what_changed;
-}
-
 void
 Region::set_name (string str)
-
 {
        if (_name != str) {
                _name = str; 
@@ -230,7 +159,7 @@ Region::set_name (string str)
 }
 
 void
-Region::set_length (jack_nframes_t len, void *src)
+Region::set_length (nframes_t len, void *src)
 {
        if (_flags & Locked) {
                return;
@@ -238,6 +167,14 @@ Region::set_length (jack_nframes_t len, void *src)
 
        if (_length != len && len != 0) {
 
+               /* check that the current _position wouldn't make the new 
+                  length impossible.
+               */
+
+               if (max_frames - len < _position) {
+                       return;
+               }
+
                if (!verify_length (len)) {
                        return;
                }
@@ -251,10 +188,6 @@ Region::set_length (jack_nframes_t len, void *src)
 
                if (!_frozen) {
                        recompute_at_end ();
-
-                       char buf[64];
-                       snprintf (buf, sizeof (buf), "length set to %u", len);
-                       save_state (buf);
                }
 
                send_change (LengthChanged);
@@ -269,9 +202,11 @@ Region::maybe_uncopy ()
 void
 Region::first_edit ()
 {
-       if (_first_edit != EditChangesNothing && _playlist) {
+       boost::shared_ptr<Playlist> pl (playlist());
+
+       if (_first_edit != EditChangesNothing && pl) {
 
-               _name = _playlist->session().new_region_name (_name);
+               _name = pl->session().new_region_name (_name);
                _first_edit = EditChangesNothing;
 
                send_change (NameChanged);
@@ -279,13 +214,35 @@ Region::first_edit ()
        }
 }
 
+bool
+Region::at_natural_position () const
+{
+       boost::shared_ptr<Playlist> pl (playlist());
+
+       if (!pl) {
+               return false;
+       }
+       
+       boost::shared_ptr<Region> whole_file_region = get_parent();
+
+       if (whole_file_region) {
+               if (_position == whole_file_region->position() + _start) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 void
 Region::move_to_natural_position (void *src)
 {
-       if (!_playlist) {
+       boost::shared_ptr<Playlist> pl (playlist());
+
+       if (!pl) {
                return;
        }
-
+       
        boost::shared_ptr<Region> whole_file_region = get_parent();
 
        if (whole_file_region) {
@@ -294,7 +251,7 @@ Region::move_to_natural_position (void *src)
 }
        
 void
-Region::special_set_position (jack_nframes_t pos)
+Region::special_set_position (nframes_t pos)
 {
        /* this is used when creating a whole file region as 
           a way to store its "natural" or "captured" position.
@@ -304,7 +261,7 @@ Region::special_set_position (jack_nframes_t pos)
 }
 
 void
-Region::set_position (jack_nframes_t pos, void *src)
+Region::set_position (nframes_t pos, void *src)
 {
        if (_flags & Locked) {
                return;
@@ -313,10 +270,14 @@ Region::set_position (jack_nframes_t pos, void *src)
        if (_position != pos) {
                _position = pos;
 
-               if (!_frozen) {
-                       char buf[64];
-                       snprintf (buf, sizeof (buf), "position set to %u", pos);
-                       save_state (buf);
+               /* check that the new _position wouldn't make the current
+                  length impossible - if so, change the length. 
+
+                  XXX is this the right thing to do?
+               */
+
+               if (max_frames - _length < _position) {
+                       _length = max_frames - _position;
                }
        }
 
@@ -328,7 +289,7 @@ Region::set_position (jack_nframes_t pos, void *src)
 }
 
 void
-Region::set_position_on_top (jack_nframes_t pos, void *src)
+Region::set_position_on_top (nframes_t pos, void *src)
 {
        if (_flags & Locked) {
                return;
@@ -336,15 +297,13 @@ Region::set_position_on_top (jack_nframes_t pos, void *src)
 
        if (_position != pos) {
                _position = pos;
-
-               if (!_frozen) {
-                       char buf[64];
-                       snprintf (buf, sizeof (buf), "position set to %u", pos);
-                       save_state (buf);
-               }
        }
 
-       _playlist->raise_region_to_top (boost::shared_ptr<Region>(this));
+       boost::shared_ptr<Playlist> pl (playlist());
+
+       if (pl) {
+               pl->raise_region_to_top (shared_from_this ());
+       }
 
        /* do this even if the position is the same. this helps out
           a GUI that has moved its representation already.
@@ -371,24 +330,18 @@ Region::nudge_position (long n, void *src)
                        _position += n;
                }
        } else {
-               if (_position < (jack_nframes_t) -n) {
+               if (_position < (nframes_t) -n) {
                        _position = 0;
                } else {
                        _position += n;
                }
        }
 
-       if (!_frozen) {
-               char buf[64];
-               snprintf (buf, sizeof (buf), "position set to %u", _position);
-               save_state (buf);
-       }
-
        send_change (PositionChanged);
 }
 
 void
-Region::set_start (jack_nframes_t pos, void *src)
+Region::set_start (nframes_t pos, void *src)
 {
        if (_flags & Locked) {
                return;
@@ -408,23 +361,17 @@ Region::set_start (jack_nframes_t pos, void *src)
                _flags = Region::Flag (_flags & ~WholeFile);
                first_edit ();
 
-               if (!_frozen) {
-                       char buf[64];
-                       snprintf (buf, sizeof (buf), "start set to %u", pos);
-                       save_state (buf);
-               }
-
                send_change (StartChanged);
        }
 }
 
 void
-Region::trim_start (jack_nframes_t new_position, void *src)
+Region::trim_start (nframes_t new_position, void *src)
 {
        if (_flags & Locked) {
                return;
        }
-       jack_nframes_t new_start;
+       nframes_t new_start;
        int32_t start_shift;
        
        if (new_position > _position) {
@@ -447,7 +394,7 @@ Region::trim_start (jack_nframes_t new_position, void *src)
 
        } else if (start_shift < 0) {
 
-               if (_start < (jack_nframes_t) -start_shift) {
+               if (_start < (nframes_t) -start_shift) {
                        new_start = 0;
                } else {
                        new_start = _start + start_shift;
@@ -464,24 +411,18 @@ Region::trim_start (jack_nframes_t new_position, void *src)
        _flags = Region::Flag (_flags & ~WholeFile);
        first_edit ();
 
-       if (!_frozen) {
-               char buf[64];
-               snprintf (buf, sizeof (buf), "slipped start to %u", _start);
-               save_state (buf);
-       }
-
        send_change (StartChanged);
 }
 
 void
-Region::trim_front (jack_nframes_t new_position, void *src)
+Region::trim_front (nframes_t new_position, void *src)
 {
        if (_flags & Locked) {
                return;
        }
 
-       jack_nframes_t end = _position + _length - 1;
-       jack_nframes_t source_zero;
+       nframes_t end = last_frame();
+       nframes_t source_zero;
 
        if (_position > _start) {
                source_zero = _position - _start;
@@ -491,7 +432,7 @@ Region::trim_front (jack_nframes_t new_position, void *src)
 
        if (new_position < end) { /* can't trim it zero or negative length */
                
-               jack_nframes_t newlen;
+               nframes_t newlen;
 
                /* can't trim it back passed where source position zero is located */
                
@@ -512,7 +453,7 @@ Region::trim_front (jack_nframes_t new_position, void *src)
 }
 
 void
-Region::trim_end (jack_nframes_t new_endpoint, void *src)
+Region::trim_end (nframes_t new_endpoint, void *src)
 {
        if (_flags & Locked) {
                return;
@@ -527,7 +468,7 @@ Region::trim_end (jack_nframes_t new_endpoint, void *src)
 }
 
 void
-Region::trim_to (jack_nframes_t position, jack_nframes_t length, void *src)
+Region::trim_to (nframes_t position, nframes_t length, void *src)
 {
        if (_flags & Locked) {
                return;
@@ -542,10 +483,10 @@ Region::trim_to (jack_nframes_t position, jack_nframes_t length, void *src)
 }
 
 void
-Region::trim_to_internal (jack_nframes_t position, jack_nframes_t length, void *src)
+Region::trim_to_internal (nframes_t position, nframes_t length, void *src)
 {
        int32_t start_shift;
-       jack_nframes_t new_start;
+       nframes_t new_start;
 
        if (_flags & Locked) {
                return;
@@ -568,7 +509,7 @@ Region::trim_to_internal (jack_nframes_t position, jack_nframes_t length, void *
 
        } else if (start_shift < 0) {
 
-               if (_start < (jack_nframes_t) -start_shift) {
+               if (_start < (nframes_t) -start_shift) {
                        new_start = 0;
                } else {
                        new_start = _start + start_shift;
@@ -603,13 +544,6 @@ Region::trim_to_internal (jack_nframes_t position, jack_nframes_t length, void *
        } 
 
        if (what_changed) {
-               
-               if (!_frozen) {
-                       char buf[64];
-                       snprintf (buf, sizeof (buf), "trimmed to %u-%u", _position, _position+_length-1);
-                       save_state (buf);
-               }
-
                send_change (what_changed);
        }
 }      
@@ -640,16 +574,6 @@ Region::set_muted (bool yn)
                        _flags = Flag (_flags & ~Muted);
                }
 
-               if (!_frozen) {
-                       char buf[64];
-                       if (yn) {
-                               snprintf (buf, sizeof (buf), "muted");
-                       } else {
-                               snprintf (buf, sizeof (buf), "unmuted");
-                       }
-                       save_state (buf);
-               }
-
                send_change (MuteChanged);
        }
 }
@@ -658,16 +582,10 @@ void
 Region::set_opaque (bool yn)
 {
        if (opaque() != yn) {
-               if (!_frozen) {
-                       char buf[64];
-                       if (yn) {
-                               snprintf (buf, sizeof (buf), "opaque");
-                               _flags = Flag (_flags|Opaque);
-                       } else {
-                               snprintf (buf, sizeof (buf), "translucent");
-                               _flags = Flag (_flags & ~Opaque);
-                       }
-                       save_state (buf);
+               if (yn) {
+                       _flags = Flag (_flags|Opaque);
+               } else {
+                       _flags = Flag (_flags & ~Opaque);
                }
                send_change (OpacityChanged);
        }
@@ -677,25 +595,19 @@ void
 Region::set_locked (bool yn)
 {
        if (locked() != yn) {
-               if (!_frozen) {
-                       char buf[64];
-                       if (yn) {
-                               snprintf (buf, sizeof (buf), "locked");
-                               _flags = Flag (_flags|Locked);
-                       } else {
-                               snprintf (buf, sizeof (buf), "unlocked");
-                               _flags = Flag (_flags & ~Locked);
-                       }
-                       save_state (buf);
+               if (yn) {
+                       _flags = Flag (_flags|Locked);
+               } else {
+                       _flags = Flag (_flags & ~Locked);
                }
                send_change (LockChanged);
        }
 }
 
 void
-Region::set_sync_position (jack_nframes_t absolute_pos)
+Region::set_sync_position (nframes_t absolute_pos)
 {
-       jack_nframes_t file_pos;
+       nframes_t file_pos;
 
        file_pos = _start + (absolute_pos - _position);
 
@@ -705,10 +617,7 @@ Region::set_sync_position (jack_nframes_t absolute_pos)
                _flags = Flag (_flags|SyncMarked);
 
                if (!_frozen) {
-                       char buf[64];
                        maybe_uncopy ();
-                       snprintf (buf, sizeof (buf), "sync point set to %u", _sync_position);
-                       save_state (buf);
                }
                send_change (SyncOffsetChanged);
        }
@@ -722,13 +631,12 @@ Region::clear_sync_position ()
 
                if (!_frozen) {
                        maybe_uncopy ();
-                       save_state ("sync point removed");
                }
                send_change (SyncOffsetChanged);
        }
 }
 
-jack_nframes_t
+nframes_t
 Region::sync_offset (int& dir) const
 {
        /* returns the sync point relative the first frame of the region */
@@ -747,11 +655,11 @@ Region::sync_offset (int& dir) const
        }
 }
 
-jack_nframes_t 
-Region::adjust_to_sync (jack_nframes_t pos)
+nframes_t 
+Region::adjust_to_sync (nframes_t pos)
 {
        int sync_dir;
-       jack_nframes_t offset = sync_offset (sync_dir);
+       nframes_t offset = sync_offset (sync_dir);
        
        if (sync_dir > 0) {
                if (max_frames - pos > offset) {
@@ -768,7 +676,7 @@ Region::adjust_to_sync (jack_nframes_t pos)
        return pos;
 }
 
-jack_nframes_t
+nframes_t
 Region::sync_position() const
 {
        if (_flags & SyncMarked) {
@@ -782,42 +690,37 @@ Region::sync_position() const
 void
 Region::raise ()
 {
-       if (_playlist == 0) {
-               return;
+       boost::shared_ptr<Playlist> pl (playlist());
+       if (pl) {
+               pl->raise_region (shared_from_this ());
        }
-
-       _playlist->raise_region (boost::shared_ptr<Region>(this));
 }
 
 void
 Region::lower ()
 {
-       if (_playlist == 0) {
-               return;
+       boost::shared_ptr<Playlist> pl (playlist());
+       if (pl) {
+               pl->lower_region (shared_from_this ());
        }
-
-       _playlist->lower_region (boost::shared_ptr<Region>(this));
 }
 
 void
 Region::raise_to_top ()
 {
-
-       if (_playlist == 0) {
-               return;
+       boost::shared_ptr<Playlist> pl (playlist());
+       if (pl) {
+               pl->raise_region_to_top (shared_from_this());
        }
-
-       _playlist->raise_region_to_top (boost::shared_ptr<Region>(this));
 }
 
 void
 Region::lower_to_bottom ()
 {
-       if (_playlist == 0) {
-               return;
+       boost::shared_ptr<Playlist> pl (playlist());
+       if (pl) {
+               pl->lower_region_to_bottom (shared_from_this());
        }
-
-       _playlist->lower_region_to_bottom (boost::shared_ptr<Region>(this));
 }
 
 void
@@ -826,12 +729,6 @@ Region::set_layer (layer_t l)
        if (_layer != l) {
                _layer = l;
                
-               if (!_frozen) {
-                       char buf[64];
-                       snprintf (buf, sizeof (buf), "layer set to %" PRIu32, _layer);
-                       save_state (buf);
-               }
-               
                send_change (LayerChanged);
        }
 }
@@ -841,8 +738,9 @@ Region::state (bool full_state)
 {
        XMLNode *node = new XMLNode ("Region");
        char buf[64];
-       
-       _id.print (buf);
+       char* fe;
+
+       _id.print (buf, sizeof (buf));
        node->add_property ("id", buf);
        node->add_property ("name", _name);
        snprintf (buf, sizeof (buf), "%u", _start);
@@ -851,6 +749,20 @@ Region::state (bool full_state)
        node->add_property ("length", buf);
        snprintf (buf, sizeof (buf), "%u", _position);
        node->add_property ("position", buf);
+       
+       switch (_first_edit) {
+       case EditChangesNothing:
+               fe = X_("nothing");
+               break;
+       case EditChangesName:
+               fe = X_("name");
+               break;
+       case EditChangesID:
+               fe = X_("id");
+               break;
+       }
+
+       node->add_property ("first_edit", fe);
 
        /* note: flags are stored by derived classes */
 
@@ -869,54 +781,83 @@ Region::get_state ()
 }
 
 int
-Region::set_state (const XMLNode& node)
+Region::set_live_state (const XMLNode& node, Change& what_changed, bool send)
 {
        const XMLNodeList& nlist = node.children();
        const XMLProperty *prop;
+       nframes_t val;
 
-       if (_extra_xml) {
-               delete _extra_xml;
-               _extra_xml = 0;
-       }
-
-       if ((prop = node.property ("id")) == 0) {
-               error << _("Session: XMLNode describing a Region is incomplete (no id)") << endmsg;
-               return -1;
-       }
-
-       _id = prop->value();
+       /* this is responsible for setting those aspects of Region state 
+          that are mutable after construction.
+       */
 
        if ((prop = node.property ("name")) == 0) {
-               error << _("Session: XMLNode describing a Region is incomplete (no name)") << endmsg;
+               error << _("XMLNode describing a Region is incomplete (no name)") << endmsg;
                return -1;
        }
 
        _name = prop->value();
 
        if ((prop = node.property ("start")) != 0) {
-               _start = (jack_nframes_t) atoi (prop->value().c_str());
+               sscanf (prop->value().c_str(), "%" PRIu32, &val);
+               if (val != _start) {
+                       what_changed = Change (what_changed|StartChanged);      
+                       _start = val;
+               }
+       } else {
+               _start = 0;
        }
 
        if ((prop = node.property ("length")) != 0) {
-               _length = (jack_nframes_t) atoi (prop->value().c_str());
+               sscanf (prop->value().c_str(), "%" PRIu32, &val);
+               if (val != _length) {
+                       what_changed = Change (what_changed|LengthChanged);
+                       _length = val;
+               }
+       } else {
+               _length = 1;
        }
 
        if ((prop = node.property ("position")) != 0) {
-               _position = (jack_nframes_t) atoi (prop->value().c_str());
+               sscanf (prop->value().c_str(), "%" PRIu32, &val);
+               if (val != _position) {
+                       what_changed = Change (what_changed|PositionChanged);
+                       _position = val;
+               }
+       } else {
+               _position = 0;
        }
 
        if ((prop = node.property ("layer")) != 0) {
-               _layer = (layer_t) atoi (prop->value().c_str());
+               layer_t x;
+               x = (layer_t) atoi (prop->value().c_str());
+               if (x != _layer) {
+                       what_changed = Change (what_changed|LayerChanged);
+                       _layer = x;
+               }
+       } else {
+               _layer = 0;
        }
 
-       /* note: derived classes set flags */
-
        if ((prop = node.property ("sync-position")) != 0) {
-               _sync_position = (jack_nframes_t) atoi (prop->value().c_str());
+               sscanf (prop->value().c_str(), "%" PRIu32, &val);
+               if (val != _sync_position) {
+                       what_changed = Change (what_changed|SyncOffsetChanged);
+                       _sync_position = val;
+               }
        } else {
                _sync_position = _start;
        }
+
+       /* XXX FIRST EDIT !!! */
        
+       /* note: derived classes set flags */
+
+       if (_extra_xml) {
+               delete _extra_xml;
+               _extra_xml = 0;
+       }
+
        for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) {
                
                XMLNode *child;
@@ -929,7 +870,31 @@ Region::set_state (const XMLNode& node)
                }
        }
 
+       if (send) {
+               send_change (what_changed);
+       }
+
+       return 0;
+}
+
+int
+Region::set_state (const XMLNode& node)
+{
+       const XMLProperty *prop;
+       Change what_changed = Change (0);
+
+       /* ID is not allowed to change, ever */
+
+       if ((prop = node.property ("id")) == 0) {
+               error << _("Session: XMLNode describing a Region is incomplete (no id)") << endmsg;
+               return -1;
+       }
+
+       _id = prop->value();
+       
        _first_edit = EditChangesNothing;
+       
+       set_live_state (node, what_changed, true);
 
        return 0;
 }
@@ -969,7 +934,6 @@ Region::thaw (const string& why)
                recompute_at_end ();
        }
                
-       save_state (why);
        StateChanged (what_changed);
 }
 
@@ -984,7 +948,7 @@ Region::send_change (Change what_changed)
                } 
        }
 
-       StateManager::send_state_changed (what_changed);
+       StateChanged (what_changed);
 }
 
 void