diff options
author | Carl Hetherington <carl@carlh.net> | 2011-10-24 19:47:06 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-10-24 19:47:06 +0000 |
commit | 8404d7ff94c6bffd150ed11a791a26ae5f1d824d (patch) | |
tree | 2d38106d575b068f05e44f0fadcea7e3f51db102 /libs/ardour | |
parent | b507805bf69dc6cef92caaced357450758a6201e (diff) |
Reset source paths on session rename (fixes #4389).
git-svn-id: svn://localhost/ardour2/branches/3.0@10299 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/session_state.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 56a1380f91..f21d80e717 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -28,8 +28,6 @@ #include <fstream> #include <string> #include <cerrno> - - #include <cstdio> /* snprintf(3) ... grrr */ #include <cmath> #include <unistd.h> @@ -53,6 +51,8 @@ #include <glibmm.h> #include <glibmm/thread.h> +#include <boost/algorithm/string.hpp> + #include "midi++/mmc.h" #include "midi++/port.h" #include "midi++/manager.h" @@ -3670,6 +3670,8 @@ Session::rename (const std::string& new_name) string newstr; bool first = true; + string const old_sources_root = _session_dir->sources_root().to_string (); + #define RENAME ::rename /* Rename: @@ -3791,6 +3793,17 @@ Session::rename (const std::string& new_name) } } + /* update file source paths */ + + for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) { + boost::shared_ptr<FileSource> fs = boost::dynamic_pointer_cast<FileSource> (i->second); + if (fs) { + string p = fs->path (); + boost::replace_all (p, old_sources_root, _session_dir->sources_root().to_string ()); + fs->set_path (p); + } + } + /* remove old name from recent sessions */ remove_recent_sessions (_path); |