enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / ardour / audio_playlist_importer.cc
index 81ad16998930532c1beebce3739ecdff38a26250..c1afdfe535e1862b24481f0bd4a77eef6c21cbe5 100644 (file)
 
 #include "ardour/audio_region_importer.h"
 #include "ardour/session.h"
-#include "ardour/playlist.h"
 #include "ardour/playlist_factory.h"
+#include "ardour/session_playlists.h"
+
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -49,7 +51,7 @@ AudioPlaylistImportHandler::AudioPlaylistImportHandler (XMLTree const & source,
 
        XMLNodeList const & pl_children = playlists->children();
        for (XMLNodeList::const_iterator it = pl_children.begin(); it != pl_children.end(); ++it) {
-               const XMLProperty* type = (*it)->property("type");
+               XMLProperty const * type = (*it)->property("type");
                if ( !type || type->value() == "audio" ) {
                        try {
                                elements.push_back (ElementPtr ( new AudioPlaylistImporter (source, session, *this, **it)));
@@ -73,7 +75,7 @@ AudioPlaylistImportHandler::get_regions (XMLNode const & node, ElementList & lis
 }
 
 void
-AudioPlaylistImportHandler::update_region_id (XMLProperty* id_prop)
+AudioPlaylistImportHandler::update_region_id (XMLProperty * id_prop)
 {
        PBD::ID old_id (id_prop->value());
        PBD::ID new_id (region_handler.get_new_id (old_id));
@@ -168,14 +170,21 @@ bool
 AudioPlaylistImporter::_prepare_move ()
 {
        // Rename
-       while (session.playlists.by_name (name) || !handler.check_name (name)) {
-               std::pair<bool, string> rename_pair = Rename (_("A playlist with this name already exists, please rename it."), name);
+       while (session.playlists->by_name (name) || !handler.check_name (name)) {
+               std::pair<bool, string> rename_pair = *Rename (_("A playlist with this name already exists, please rename it."), name);
                if (!rename_pair.first) {
                        return false;
                }
                name = rename_pair.second;
        }
-       xml_playlist.property ("name")->set_value (name);
+
+       XMLProperty * p = xml_playlist.property ("name");
+       if (!p) {
+               error << _("badly-formed XML in imported playlist") << endmsg;
+               return false;
+       }
+
+       p->set_value (name);
        handler.add_name (name);
 
        return true;
@@ -210,22 +219,23 @@ AudioPlaylistImporter::_move ()
        // Update region ids in crossfades
        XMLNodeList crossfades = xml_playlist.children("Crossfade");
        for (XMLNodeIterator it = crossfades.begin(); it != crossfades.end(); ++it) {
-               XMLProperty* in = (*it)->property("in");
-               XMLProperty* out = (*it)->property("out");
+               XMLProperty * in = (*it)->property("in");
+               XMLProperty * out = (*it)->property("out");
                if (!in || !out) {
                        error << string_compose (X_("AudioPlaylistImporter (%1): did not find the \"in\" or \"out\" property from a crossfade"), name) << endmsg;
+                       continue; // or fatal?
                }
 
                handler.update_region_id (in);
                handler.update_region_id (out);
 
                // rate convert length and position
-               XMLProperty* length = (*it)->property("length");
+               XMLProperty * length = (*it)->property("length");
                if (length) {
                        length->set_value (rate_convert_samples (length->value()));
                }
 
-               XMLProperty* position = (*it)->property("position");
+               XMLProperty * position = (*it)->property("position");
                if (position) {
                        position->set_value (rate_convert_samples (position->value()));
                }
@@ -251,3 +261,8 @@ AudioPlaylistImporter::populate_region_list ()
        }
 }
 
+string
+UnusedAudioPlaylistImportHandler::get_info () const
+{
+       return _("Audio Playlists (unused)");
+}