fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / audio_region_importer.cc
index 91c362d042e8602fba3bda807aa4c799c604fad1..8fc5c53d6d4ecc6704db1e074aefd68c0fa4d907 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <sstream>
 
+#include <glibmm/miscutils.h>
+
 #include "pbd/failed_constructor.h"
 #include "pbd/compose.h"
 #include "pbd/error.h"
@@ -31,7 +33,7 @@
 #include "ardour/region_factory.h"
 #include "ardour/session_directory.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -232,10 +234,9 @@ AudioRegionImporter::parse_source_xml ()
 {
        uint32_t channels;
        char buf[128];
-       PBD::sys::path source_dir = get_sound_dir (source);
-       PBD::sys::path source_path;
+       std::string source_dir(get_sound_dir (source));
        XMLNode * source_node;
-       XMLProperty *prop;
+       XMLProperty const * prop;
 
        // Get XML for sources
        if (!(source_node = source.root()->child (X_("Sources")))) {
@@ -266,15 +267,12 @@ AudioRegionImporter::parse_source_xml ()
                for (XMLNodeList::const_iterator it = sources.begin(); it != sources.end(); ++it) {
                        prop = (*it)->property ("id");
                        if (prop && !source_id.compare (prop->value())) {
-                               source_path = source_dir;
                                prop = (*it)->property ("name");
                                if (!prop) {
                                        error << string_compose (X_("AudioRegionImporter (%1): source %2 has no \"name\" property"), name, source_id) << endmsg;
                                        return false;
                                }
-                               source_path /= prop->value();
-                               filenames.push_back (source_path.to_string());
-
+                               filenames.push_back (Glib::build_filename (source_dir, prop->value()));
                                source_found = true;
                                break;
                        }
@@ -289,15 +287,11 @@ AudioRegionImporter::parse_source_xml ()
        return true;
 }
 
-PBD::sys::path
+std::string
 AudioRegionImporter::get_sound_dir (XMLTree const & tree)
 {
-       PBD::sys::path source_dir = tree.filename();
-       source_dir = source_dir.branch_path();
-       SessionDirectory session_dir(source_dir);
-       source_dir = session_dir.sound_path();
-
-       return source_dir;
+       SessionDirectory session_dir(Glib::path_get_dirname (tree.filename()));
+       return session_dir.sound_path();
 }
 
 void
@@ -356,7 +350,7 @@ AudioRegionImporter::prepare_sources ()
 
        // import files
        // TODO: threading & exception handling
-       session.import_audiofiles (status);
+       session.import_files (status);
 
        // Add imported sources to handlers map
        std::vector<string>::iterator file_it = status.paths.begin();