Prevent deletion of last port using the PortMatrix.

This commit is contained in:
Robin Gareus 2016-04-03 23:24:03 +02:00
parent 514b8a23d0
commit 56352723d8

View file

@ -747,23 +747,31 @@ PortMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
void void
PortMatrix::remove_channel (ARDOUR::BundleChannel b) PortMatrix::remove_channel (ARDOUR::BundleChannel b)
{ {
std::string errmsg;
boost::shared_ptr<IO> io = io_from_bundle (b.bundle); boost::shared_ptr<IO> io = io_from_bundle (b.bundle);
boost::shared_ptr<Port> p = io->nth (b.channel);
if (io) { if (!io || !p) {
boost::shared_ptr<Port> p = io->nth (b.channel); return;
if (p) { }
int const r = io->remove_port (p, this);
if (r == -1) { if (io->n_ports ().n_total () == 1) {
ArdourDialog d (_("Port removal not allowed")); errmsg = _("The last port cannot be removed");
Label l (_("This port cannot be removed.\nEither the first plugin in the track or buss cannot accept\nthe new number of inputs or the last plugin has more outputs.")); } else {
d.get_vbox()->pack_start (l); if (-1 == io->remove_port (p, this)) {
d.add_button (Stock::OK, RESPONSE_ACCEPT); errmsg = _("This port cannot be removed.\nEither the first plugin in the track or buss cannot accept\nthe new number of inputs or the last plugin has more outputs.");
d.set_modal (true);
d.show_all ();
d.run ();
}
} }
} }
if (!errmsg.empty ()) {
ArdourDialog d (_("Port removal not allowed"));
Label l (errmsg);
d.get_vbox()->pack_start (l);
d.add_button (Stock::OK, RESPONSE_ACCEPT);
d.set_modal (true);
d.show_all ();
d.run ();
}
} }
void void