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>
Fri, 4 Apr 2014 19:26:44 +0000 (15:26 -0400)
libs/ardour/ardour/file_source.h
libs/ardour/ardour/smf_source.h
libs/ardour/midi_source.cc
libs/ardour/smf_source.cc

index 34e84c242811f8b1162a2e0c06673254ae21e497..e0db1d25b765ebfcb789e5c87d1f968fa77d65c8 100644 (file)
@@ -82,6 +82,8 @@ public:
        
        static PBD::Signal2<int,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 82e6252b4507748e6b4da3e58536ec8dd05b64b1..6e69b7b2f33f83056949c723eeeb4aeabc4e96e2 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 1887b74302104db67fc2018d8bc3bb43f5d5994e..8034634ba7da01c7aa47724c47dfb2174ad09603 100644 (file)
@@ -38,6 +38,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"
@@ -380,6 +381,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 c504f5000628f67008c0a6e5478194414f952435..62ecab1397587a2bd0bc5bf3b8ebc5dca79096e7 100644 (file)
@@ -73,9 +73,10 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
                return;
        }
 
-       if (open(_path)) {
+       if (open (_path)) {
                throw failed_constructor ();
        }
+
        _open = true;
 }
 
@@ -658,3 +659,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));
+}