various minor fixes for crashes reported by nowhiskey
[ardour.git] / libs / ardour / audioengine.cc
index 15ccd852f73a14be514e4f3a94a53b77c8fb70ce..a0287ab6967291fc8373e0f8c7d2db044f0db318 100644 (file)
@@ -1227,8 +1227,16 @@ AudioEngine::reconnect_to_jack ()
        for (PortConnections::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
                
                int err;
+               jack_client_t* j = _jack;
+
+               /* JACK could have zombified us. */
+
+               if (!j) {
+                       error << _("Disconnected from JACK while reconnecting. You should quit Ardour now.") << endmsg;
+                       return -1;
+               }
                
-               if ((err = jack_connect (_jack, (*i).first.c_str(), (*i).second.c_str())) != 0) {
+               if ((err = jack_connect (j, (*i).first.c_str(), (*i).second.c_str())) != 0) {
                        if (err != EEXIST) {
                                error << string_compose (_("could not reconnect %1 and %2 (err = %3)"),
                                                  (*i).first, (*i).second, err)