Merge branch 'master' into saveas
[ardour.git] / libs / ardour / io.cc
index 2cc213f7975932624527f6ee58cd1c850aa14c01..69f7c9053ee4c6ffe6db10f10d32435709584eb6 100644 (file)
@@ -527,7 +527,7 @@ IO::state (bool /*full_state*/)
        string str;
        vector<string>::iterator ci;
        int n;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
        Glib::Threads::Mutex::Lock lm (io_lock);
 
        node->add_property("name", _name);
@@ -588,7 +588,7 @@ IO::set_state (const XMLNode& node, int version)
 
        const XMLProperty* prop;
        XMLNodeConstIterator iter;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
 
        /* force use of non-localized representation of decimal point,
           since we use it a lot in XML files and so forth.
@@ -644,7 +644,7 @@ IO::set_state_2X (const XMLNode& node, int version, bool in)
 {
        const XMLProperty* prop;
        XMLNodeConstIterator iter;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
 
        /* force use of non-localized representation of decimal point,
           since we use it a lot in XML files and so forth.
@@ -854,6 +854,7 @@ IO::get_port_counts (const XMLNode& node, int version, ChanCount& n, boost::shar
        for (iter = node.children().begin(); iter != node.children().end(); ++iter) {
 
                if ((*iter)->name() == X_("Bundle")) {
+                       prop = (*iter)->property ("name");
                        if ((c = find_possible_bundle (prop->value())) != 0) {
                                n = ChanCount::max (n, c->nchannels());
                                return 0;
@@ -1039,7 +1040,8 @@ IO::make_connections_2X (const XMLNode& node, int /*version*/, bool in)
                                        if (p != string::npos) {
                                                ports[x].replace (p, 4, "/audio_out");
                                        }
-                                       nth(i)->connect (ports[x]);
+                                       if (NULL != nth(i).get())
+                                               nth(i)->connect (ports[x]);
                                }
                        }
 
@@ -1081,7 +1083,8 @@ IO::make_connections_2X (const XMLNode& node, int /*version*/, bool in)
                                        if (p != string::npos) {
                                                ports[x].replace (p, 3, "/audio_in");
                                        }
-                                       nth(i)->connect (ports[x]);
+                                       if (NULL != nth(i).get())
+                                               nth(i)->connect (ports[x]);
                                }
                        }
 
@@ -1097,7 +1100,6 @@ int
 IO::set_ports (const string& str)
 {
        vector<string> ports;
-       int i;
        int n;
        uint32_t nports;
 
@@ -1114,14 +1116,10 @@ IO::set_ports (const string& str)
                }
        }
 
-       string::size_type start, end, ostart;
-
-       ostart = 0;
-       start = 0;
-       end = 0;
-       i = 0;
-
-       while ((start = str.find_first_of ('{', ostart)) != string::npos) {
+       string::size_type start  = 0;
+       string::size_type end    = 0;
+       string::size_type ostart = 0;
+       for (int i = 0; (start = str.find_first_of ('{', ostart)) != string::npos; ++i) {
                start += 1;
 
                if ((end = str.find_first_of ('}', start)) == string::npos) {
@@ -1142,7 +1140,6 @@ IO::set_ports (const string& str)
                }
 
                ostart = end+1;
-               i++;
        }
 
        return 0;
@@ -1179,7 +1176,6 @@ IO::parse_gain_string (const string& str, vector<string>& ports)
 {
        string::size_type pos, opos;
 
-       pos = 0;
        opos = 0;
        ports.clear ();
 
@@ -1611,8 +1607,10 @@ IO::connected_to (boost::shared_ptr<const IO> other) const
 
        for (i = 0; i < no; ++i) {
                for (j = 0; j < ni; ++j) {
-                       if (nth(i)->connected_to (other->nth(j)->name())) {
-                               return true;
+                       if ((NULL != nth(i).get()) && (NULL != other->nth(j).get())) {
+                               if (nth(i)->connected_to (other->nth(j)->name())) {
+                                       return true;
+                               }
                        }
                }
        }