diff options
-rw-r--r-- | libs/ardour/ardour/recent_sessions.h | 1 | ||||
-rw-r--r-- | libs/ardour/recent_sessions.cc | 25 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 10 |
3 files changed, 36 insertions, 0 deletions
diff --git a/libs/ardour/ardour/recent_sessions.h b/libs/ardour/ardour/recent_sessions.h index e6d2f83bcc..2951496849 100644 --- a/libs/ardour/ardour/recent_sessions.h +++ b/libs/ardour/ardour/recent_sessions.h @@ -30,6 +30,7 @@ namespace ARDOUR { int read_recent_sessions (RecentSessions& rs); int store_recent_sessions (std::string name, std::string path); int write_recent_sessions (RecentSessions& rs); + int remove_recent_sessions (const std::string& path); }; // namespace ARDOUR #endif // __ardour_recent_sessions_h__ diff --git a/libs/ardour/recent_sessions.cc b/libs/ardour/recent_sessions.cc index dfe85190b3..adc25294fb 100644 --- a/libs/ardour/recent_sessions.cc +++ b/libs/ardour/recent_sessions.cc @@ -137,3 +137,28 @@ ARDOUR::store_recent_sessions (string name, string path) return ARDOUR::write_recent_sessions (rs); } +int +ARDOUR::remove_recent_sessions (const string& path) +{ + RecentSessions rs; + bool write = false; + + if (ARDOUR::read_recent_sessions (rs) < 0) { + return -1; + } + + for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { + if (i->second == path) { + rs.erase (i); + write = true; + break; + } + } + + if (write) { + return ARDOUR::write_recent_sessions (rs); + } else { + return 1; + } +} + diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 0973e294c5..1b8c7c0ba0 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -100,6 +100,7 @@ #include "ardour/processor.h" #include "ardour/port.h" #include "ardour/proxy_controllable.h" +#include "ardour/recent_sessions.h" #include "ardour/region_factory.h" #include "ardour/route_group.h" #include "ardour/send.h" @@ -3787,6 +3788,10 @@ Session::rename (const std::string& new_name) } } + /* remove old name from recent sessions */ + + remove_recent_sessions (_path); + _path = newpath; _current_snapshot_name = new_name; _name = new_name; @@ -3797,6 +3802,11 @@ Session::rename (const std::string& new_name) save_state (_current_snapshot_name); + + /* add to recent sessions */ + + store_recent_sessions (new_name, _path); + return 0; #undef RENAME |