diff options
author | Robin Gareus <robin@gareus.org> | 2019-03-18 15:33:05 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-03-18 15:36:58 +0100 |
commit | 4706201425e9ce7d8f4609cb920f4b28f261ee63 (patch) | |
tree | c802301407df9d92f307cd76feccc1bcd9ef2a2c /libs/ardour/session_state.cc | |
parent | bd9d848058cd4b157388e9c8ef2f781554447d2a (diff) |
NO-OP: Use API to set/test state-of-the-state
Diffstat (limited to 'libs/ardour/session_state.cc')
-rw-r--r-- | libs/ardour/session_state.cc | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1a25fd4e36..9773364523 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -364,7 +364,7 @@ Session::post_engine_init () auto_connect_master_bus (); } - _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave|Dirty)); + _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave | Dirty)); /* update latencies */ @@ -784,7 +784,7 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot lx.acquire (); } - if (!_writable || (_state_of_the_state & CannotSave)) { + if (!_writable || cannot_save()) { return 1; } @@ -920,13 +920,7 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot save_history (snapshot_name); if (mark_as_clean) { - bool was_dirty = dirty(); - - _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); - - if (was_dirty) { - DirtyChanged (); /* EMIT SIGNAL */ - } + unset_dirty (/* EMIT SIGNAL */ true); } StateSaved (snapshot_name); /* EMIT SIGNAL */ @@ -1445,7 +1439,7 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass */ if (!was_dirty) { - _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); + unset_dirty (); } } @@ -1544,7 +1538,7 @@ Session::set_state (const XMLNode& node, int version) XMLNode* child; int ret = -1; - _state_of_the_state = StateOfTheState (_state_of_the_state|CannotSave); + _state_of_the_state = StateOfTheState (_state_of_the_state | CannotSave); if (node.name() != X_("Session")) { fatal << _("programming error: Session: incorrect XML node sent to set_state()") << endmsg; @@ -2320,7 +2314,7 @@ Session::reset_write_sources (bool mark_write_complete, bool force) for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i); if (tr) { - _state_of_the_state = StateOfTheState (_state_of_the_state|InCleanup); + _state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup); tr->reset_write_sources(mark_write_complete, force); _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup); } @@ -2488,7 +2482,7 @@ Session::XMLSourceFactory (const XMLNode& node) int Session::save_template (const string& template_name, const string& description, bool replace_existing) { - if ((_state_of_the_state & CannotSave) || template_name.empty ()) { + if (cannot_save () || template_name.empty ()) { return -1; } @@ -3293,7 +3287,7 @@ Session::can_cleanup_peakfiles () const if (deletion_in_progress()) { return false; } - if (!_writable || (_state_of_the_state & CannotSave)) { + if (!_writable || cannot_save ()) { warning << _("Cannot cleanup peak-files for read-only session.") << endmsg; return false; } @@ -3366,7 +3360,7 @@ Session::cleanup_sources (CleanupReport& rep) Searchpath msp; set<boost::shared_ptr<Source> > sources_used_by_this_snapshot; - _state_of_the_state = (StateOfTheState) (_state_of_the_state | InCleanup); + _state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup); /* this is mostly for windows which doesn't allow file * renaming if the file is in use. But we don't special @@ -3650,7 +3644,7 @@ Session::cleanup_sources (CleanupReport& rep) ret = 0; out: - _state_of_the_state = (StateOfTheState) (_state_of_the_state & ~InCleanup); + _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup); return ret; } @@ -3685,7 +3679,7 @@ Session::set_dirty () } /* never mark session dirty during loading */ - if (_state_of_the_state & (Loading | Deletion)) { + if (loading () || deletion_in_progress ()) { return; } @@ -3706,6 +3700,18 @@ Session::set_clean () } void +Session::unset_dirty (bool emit_dirty_changed) +{ + bool was_dirty = dirty(); + + _state_of_the_state = StateOfTheState (_state_of_the_state & (~Dirty)); + + if (was_dirty && emit_dirty_changed) { + DirtyChanged (); /* EMIT SIGNAL */ + } +} + +void Session::set_deletion_in_progress () { _state_of_the_state = StateOfTheState (_state_of_the_state | Deletion); @@ -3735,7 +3741,7 @@ struct null_deleter { void operator()(void const *) const {} }; void Session::remove_controllable (Controllable* c) { - if (_state_of_the_state & Deletion) { + if (deletion_in_progress()) { return; } @@ -4274,7 +4280,7 @@ Session::rename (const std::string& new_name) string const old_sources_root = _session_dir->sources_root(); - if (!_writable || (_state_of_the_state & CannotSave)) { + if (!_writable || cannot_save ()) { error << _("Cannot rename read-only session.") << endmsg; return 0; // don't show "messed up" warning } @@ -5125,7 +5131,7 @@ Session::save_as (SaveAs& saveas) */ if (!saveas.include_media) { - _state_of_the_state = StateOfTheState (_state_of_the_state & ~Dirty); + unset_dirty (); } save_state ("", false, false, !saveas.include_media); |