Add a null check to ports when loading an export channel from xml + fix indentation...
authorSakari Bergen <sakari.bergen@beatwaves.net>
Sat, 11 Dec 2010 20:56:53 +0000 (20:56 +0000)
committerSakari Bergen <sakari.bergen@beatwaves.net>
Sat, 11 Dec 2010 20:56:53 +0000 (20:56 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8249 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audioengine.cc
libs/ardour/export_channel.cc

index 7df9d16e90e946cba06b15ebf61aa88415482180..7da687657759603ce29b1a5e6916d33be683c081 100644 (file)
@@ -979,11 +979,11 @@ AudioEngine::get_port_by_name (const string& portname)
        }
 
        if (portname.find_first_of (':') != string::npos) {
-                if (portname.substr (0, jack_client_name.length ()) != jack_client_name) {
-                        /* not an ardour: port */
-                        return 0;
-                }
-        }
+               if (portname.substr (0, jack_client_name.length ()) != jack_client_name) {
+                       /* not an ardour: port */
+                       return 0;
+               }
+       }
 
        std::string const rel = make_port_name_relative (portname);
 
index 0f2548dd00b17247e13512822f8ca57a5560b880..9c0bc38792ea4be76b0507f205f4b134d712b6d7 100644 (file)
@@ -26,6 +26,8 @@
 #include "ardour/export_failed.h"
 #include "ardour/session.h"
 
+#include "pbd/error.h"
+
 using namespace ARDOUR;
 
 bool
@@ -72,7 +74,13 @@ PortExportChannel::set_state (XMLNode * node, Session & session)
        XMLNodeList xml_ports = node->children ("Port");
        for (XMLNodeList::iterator it = xml_ports.begin(); it != xml_ports.end(); ++it) {
                if ((prop = (*it)->property ("name"))) {
-                       ports.insert (dynamic_cast<AudioPort *> (session.engine().get_port_by_name (prop->value())));
+                       std::string const & name = prop->value();
+                       AudioPort * port = dynamic_cast<AudioPort *> (session.engine().get_port_by_name (name));
+                       if (port) {
+                               ports.insert (port);
+                       } else {
+                               PBD::warning << string_compose (_("Could not get port for export channel \"%1\", dropping the channel"), name) << endmsg;
+                       }
                }
        }
 }