after cloning a MIDI region, mark the source file as non-removable. Fixes reports...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 4 Apr 2014 19:26:44 +0000 (15:26 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 14 Apr 2014 17:00:24 +0000 (13:00 -0400)
libs/ardour/ardour/file_source.h
libs/ardour/ardour/smf_source.h
libs/ardour/midi_source.cc
libs/ardour/smf_source.cc

index 3d9c8c623f0e53ef2afe200f6ecc3807126f6287..6991840beb4803a6bd7b6835ea5254e319c45dad 100644 (file)
@@ -82,6 +82,8 @@ public:
        
        static PBD::Signal3<int,std::string,std::string,std::vector<std::string> > AmbiguousFileName;
 
+       virtual void prevent_deletion ();
+
 protected:
        FileSource (Session& session, DataType type,
                    const std::string& path,
@@ -103,7 +105,6 @@ protected:
        std::string _origin;
        bool        _open;
 
-       void prevent_deletion ();
 };
 
 } // namespace ARDOUR
index ca337a62c2aaf893e177e977dde988b0ac24baa6..e422d37f62d21a5e551efbe19602da7ee274913b 100644 (file)
@@ -69,6 +69,8 @@ public:
 
        static bool safe_midi_file_extension (const std::string& path);
 
+       void prevent_deletion ();
+
   protected:
        void set_path (const std::string& newpath);
 
index 124d3f7c9bf11b4443befe29d068bbce86bcf074..79922571c12ddf5f052da9224537d400ae4e08d8 100644 (file)
@@ -39,6 +39,7 @@
 #include "ardour/midi_model.h"
 #include "ardour/midi_state_tracker.h"
 #include "ardour/midi_source.h"
+#include "ardour/file_source.h"
 #include "ardour/session.h"
 #include "ardour/session_directory.h"
 #include "ardour/source_factory.h"
@@ -381,6 +382,10 @@ MidiSource::clone (const string& path, Evoral::MusicalTime begin, Evoral::Musica
        } else {
                newsrc->set_model (_model);
        }
+       
+       /* this file is not removable (but since it is MIDI, it is mutable) */
+
+       boost::dynamic_pointer_cast<FileSource> (newsrc)->prevent_deletion ();
 
        return newsrc;
 }
index 52c950e76f86ad1e2c21625edea9425e91ab288e..4167bea877301efee18bf4ed89536ac794f8ca29 100644 (file)
@@ -72,9 +72,10 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
                return;
        }
 
-       if (open(_path)) {
+       if (open (_path)) {
                throw failed_constructor ();
        }
+
        _open = true;
 }
 
@@ -657,3 +658,12 @@ SMFSource::ensure_disk_file ()
        }
 }
 
+void
+SMFSource::prevent_deletion ()
+{
+       /* Unlike the audio case, the MIDI file remains mutable (because we can
+          edit MIDI data)
+       */
+  
+       _flags = Flag (_flags & ~(Removable|RemovableIfEmpty|RemoveAtDestroy));
+}