summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor_audio_import.cc46
-rw-r--r--gtk2_ardour/interthread_progress_window.cc1
-rw-r--r--libs/ardour/ardour/region_factory.h2
-rw-r--r--libs/ardour/region_factory.cc25
4 files changed, 71 insertions, 3 deletions
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index cd3c76a4ad..852958b798 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -359,6 +359,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
if (cancel) {
ok = false;
} else {
+ ipw.show ();
ok = (import_sndfiles (paths, mode, quality, pos, 1, 1, track, false) == 0);
}
@@ -392,6 +393,8 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode
pos = -1;
}
+ ipw.show ();
+
switch (chns) {
case Editing::ImportDistinctFiles:
@@ -505,6 +508,41 @@ int
Editor::import_sndfiles (vector<string> paths, ImportMode mode, SrcQuality quality, framepos_t& pos,
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace)
{
+ /* check for existing wholefile regions of the same name,
+ which can happen when we import foo.wav but end up with foo-L.wav
+ and foo-R.wav inside the session. this case doesn't trigger
+ source name collisions, so we have to catch it at the region
+ name level.
+ */
+
+ string region_name = region_name_from_path (paths.front(), true, false);
+
+ if (RegionFactory::wholefile_region_by_name (region_name)) {
+ string message = string_compose ( _("You appear to have already imported this file, since a region called %1 already exists.\nDo you really want to import it again?"),
+ region_name);
+ MessageDialog dialog (message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL, true);
+ int ret;
+
+ dialog.show ();
+ ret = dialog.run ();
+ dialog.hide ();
+
+ if (ret != RESPONSE_OK) {
+ return -1;
+ }
+
+ int l = 0;
+
+ while (RegionFactory::region_by_name (region_name) && ++l < 999) {
+ region_name = bump_name_once (region_name, '.');
+ }
+
+ if (l == 999) {
+ error << string_compose (_("Too many regions already named something like \"%1\""), paths.front()) << endmsg;
+ return -1;
+ }
+ }
+
import_status.paths = paths;
import_status.done = false;
import_status.cancel = false;
@@ -749,6 +787,12 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos,
region_name = region_name_from_path (paths.front(), (sources.size() > 1), false);
+ /* we checked in import_sndfiles() that there were not too many */
+
+ while (RegionFactory::region_by_name (region_name)) {
+ region_name = bump_name_once (region_name, '.');
+ }
+
PropertyList plist;
plist.add (ARDOUR::Properties::start, 0);
@@ -929,7 +973,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region, uint32_t
existing_track = mt.front();
}
-
+
existing_track->set_name (region->name());
}
diff --git a/gtk2_ardour/interthread_progress_window.cc b/gtk2_ardour/interthread_progress_window.cc
index 6cd1d8686a..8d446830f3 100644
--- a/gtk2_ardour/interthread_progress_window.cc
+++ b/gtk2_ardour/interthread_progress_window.cc
@@ -49,6 +49,7 @@ InterthreadProgressWindow::InterthreadProgressWindow (ARDOUR::InterThreadInfo* i
set_default_size (200, 100);
show_all ();
+ hide ();
Glib::signal_timeout().connect (sigc::mem_fun (*this, &InterthreadProgressWindow::update), 100);
}
diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h
index e99b9c80df..f9ed868f4f 100644
--- a/libs/ardour/ardour/region_factory.h
+++ b/libs/ardour/ardour/region_factory.h
@@ -42,7 +42,9 @@ class RegionFactory {
public:
typedef std::map<PBD::ID,boost::shared_ptr<Region> > RegionMap;
+ static boost::shared_ptr<Region> wholefile_region_by_name (const std::string& name);
static boost::shared_ptr<Region> region_by_id (const PBD::ID&);
+ static boost::shared_ptr<Region> region_by_name (const std::string& name);
static const RegionMap all_regions() { return region_map; }
static void clear_map ();
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 44615e2182..6f49d8c5b3 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -327,13 +327,34 @@ RegionFactory::region_by_id (const PBD::ID& id)
RegionMap::iterator i = region_map.find (id);
if (i == region_map.end()) {
- cerr << "ID " << id << " not found in region map\n";
return boost::shared_ptr<Region>();
}
return i->second;
}
-
+
+boost::shared_ptr<Region>
+RegionFactory::wholefile_region_by_name (const std::string& name)
+{
+ for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
+ if (i->second->whole_file() && i->second->name() == name) {
+ return i->second;
+ }
+ }
+ return boost::shared_ptr<Region>();
+}
+
+boost::shared_ptr<Region>
+RegionFactory::region_by_name (const std::string& name)
+{
+ for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
+ if (i->second->name() == name) {
+ return i->second;
+ }
+ }
+ return boost::shared_ptr<Region>();
+}
+
void
RegionFactory::clear_map ()
{