summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-04-03 23:24:03 +0200
committerRobin Gareus <robin@gareus.org>2016-04-03 23:24:03 +0200
commit56352723d8388d0eb1f2c93c9ed84b00226ab7c3 (patch)
tree7b34b63e7b3f23de2970f48c5b887480ba99c94e /gtk2_ardour/port_matrix.cc
parent514b8a23d0329b3371753d6fcc375c4d30e31a56 (diff)
Prevent deletion of last port using the PortMatrix.
Diffstat (limited to 'gtk2_ardour/port_matrix.cc')
-rw-r--r--gtk2_ardour/port_matrix.cc34
1 files changed, 21 insertions, 13 deletions
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 34e0f68c7e..11a76dddc6 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -747,23 +747,31 @@ PortMatrix::can_remove_channels (boost::shared_ptr<Bundle> b) const
void
PortMatrix::remove_channel (ARDOUR::BundleChannel b)
{
+ std::string errmsg;
boost::shared_ptr<IO> io = io_from_bundle (b.bundle);
+ boost::shared_ptr<Port> p = io->nth (b.channel);
- if (io) {
- boost::shared_ptr<Port> p = io->nth (b.channel);
- if (p) {
- int const r = io->remove_port (p, this);
- if (r == -1) {
- ArdourDialog d (_("Port removal not allowed"));
- 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."));
- d.get_vbox()->pack_start (l);
- d.add_button (Stock::OK, RESPONSE_ACCEPT);
- d.set_modal (true);
- d.show_all ();
- d.run ();
- }
+ if (!io || !p) {
+ return;
+ }
+
+ if (io->n_ports ().n_total () == 1) {
+ errmsg = _("The last port cannot be removed");
+ } else {
+ if (-1 == io->remove_port (p, this)) {
+ 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.");
}
}
+
+ 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