3.0 version of previous 2.X change to always prevent deletion of existing sources

git-svn-id: svn://localhost/ardour2/branches/3.0@8842 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-02-14 16:04:53 +00:00
parent b307462f4f
commit 7ac5d03cb8
3 changed files with 22 additions and 1 deletions

View file

@ -99,6 +99,8 @@ protected:
uint16_t _channel;
bool _within_session;
std::string _origin;
void prevent_deletion ();
};
} // namespace ARDOUR

View file

@ -62,6 +62,8 @@ FileSource::FileSource (Session& session, DataType type, const string& path, con
, _origin (origin)
{
set_within_session_from_path (path);
prevent_deletion ();
}
FileSource::FileSource (Session& session, const XMLNode& node, bool /*must_exist*/)
@ -75,6 +77,23 @@ FileSource::FileSource (Session& session, const XMLNode& node, bool /*must_exist
_path = _name;
_within_session = true;
prevent_deletion ();
}
void
FileSource::prevent_deletion ()
{
/* if this file already exists, it cannot be removed, ever
*/
if (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)) {
if (!(_flags & Destructive)) {
mark_immutable ();
} else {
_flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy));
}
}
}
bool

View file

@ -612,7 +612,7 @@ bool
SndFileSource::set_destructive (bool yn)
{
if (yn) {
_flags = Flag (_flags | Destructive);
_flags = Flag (_flags | Writable | Destructive);
if (!xfade_buf) {
xfade_buf = new Sample[xfade_frames];
}