Fix a memory leak.
[ardour.git] / libs / ardour / export_channel.cc
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;
+                       }
                }
        }
 }