From 8404d7ff94c6bffd150ed11a791a26ae5f1d824d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 24 Oct 2011 19:47:06 +0000 Subject: Reset source paths on session rename (fixes #4389). git-svn-id: svn://localhost/ardour2/branches/3.0@10299 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session_state.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'libs/ardour') 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 #include #include - - #include /* snprintf(3) ... grrr */ #include #include @@ -53,6 +51,8 @@ #include #include +#include + #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 fs = boost::dynamic_pointer_cast (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); -- cgit v1.2.3