diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-05-29 16:27:33 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-05-29 16:27:41 -0400 |
commit | be575b7945eace2755960fe85145e445f9a9cf6c (patch) | |
tree | 44342ebec97caeac288bca1d8c8833ac2e4482af | |
parent | c6930c1aef2102dd3872ff12629358aae9f28132 (diff) |
fix data loss/file deletion caused by mistaken used of Session::source_by_path() to check if an AUDIO filesource with a given path already exists.
::source_by_path() was written for MIDI files only. I fixed the call and renamed the two similar functions (one for audio and one for MIDI) to make it more clear.
-rw-r--r-- | gtk2_ardour/editor_audio_import.cc | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 4 | ||||
-rw-r--r-- | libs/ardour/import.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session.cc | 8 |
4 files changed, 8 insertions, 8 deletions
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index da70df5c15..dd706496e3 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -611,7 +611,7 @@ Editor::embed_sndfiles (vector<string> paths, bool multifile, boost::shared_ptr<Source> s; - if ((s = _session->source_by_path_and_channel (path, n)) == 0) { + if ((s = _session->audio_source_by_path_and_channel (path, n)) == 0) { source = boost::dynamic_pointer_cast<AudioFileSource> ( SourceFactory::createExternal (DataType::AUDIO, *_session, diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 5f1c02f805..89c33f23ec 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -585,8 +585,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop boost::shared_ptr<MidiSource> create_midi_source_by_stealing_name (boost::shared_ptr<Track>); boost::shared_ptr<Source> source_by_id (const PBD::ID&); - boost::shared_ptr<AudioFileSource> source_by_path_and_channel (const std::string&, uint16_t) const; - boost::shared_ptr<MidiSource> source_by_path (const std::string&) const; + boost::shared_ptr<AudioFileSource> audio_source_by_path_and_channel (const std::string&, uint16_t) const; + boost::shared_ptr<MidiSource> midi_source_by_path (const std::string&) const; uint32_t count_sources_by_origin (const std::string&); void add_playlist (boost::shared_ptr<Playlist>, bool unused = false); diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index b66f354224..3ab46bfec5 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -202,7 +202,7 @@ map_existing_mono_sources (const vector<string>& new_paths, Session& /*sess*/, for (vector<string>::const_iterator i = new_paths.begin(); i != new_paths.end(); ++i) { - boost::shared_ptr<Source> source = session->source_by_path_and_channel(*i, 0); + boost::shared_ptr<Source> source = session->audio_source_by_path_and_channel(*i, 0); if (source == 0) { error << string_compose(_("Could not find a source for %1 even though we are updating this file!"), (*i)) << endl; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 04c86dc979..0f0eb5b8f1 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -3311,7 +3311,7 @@ Session::source_by_id (const PBD::ID& id) } boost::shared_ptr<AudioFileSource> -Session::source_by_path_and_channel (const string& path, uint16_t chn) const +Session::audio_source_by_path_and_channel (const string& path, uint16_t chn) const { /* Restricted to audio files because only audio sources have channel as a property. @@ -3332,7 +3332,7 @@ Session::source_by_path_and_channel (const string& path, uint16_t chn) const } boost::shared_ptr<MidiSource> -Session::source_by_path (const std::string& path) const +Session::midi_source_by_path (const std::string& path) const { /* Restricted to MIDI files because audio sources require a channel for unique identification, in addition to a path. @@ -3487,7 +3487,7 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha string possible_path = Glib::build_filename (spath, buf); - if (source_by_path (possible_path)) { + if (audio_source_by_path_and_channel (possible_path, chan)) { existing++; break; } @@ -3553,7 +3553,7 @@ Session::new_midi_source_name (const string& owner_name) existing++; } - if (source_by_path (possible_path)) { + if (midi_source_by_path (possible_path)) { existing++; } } |