From 0b6d851d7ca1ec00aa957232807cc7fb656e1daa Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 18 Sep 2017 16:36:57 +0200 Subject: [PATCH] =?utf8?q?Bugfix:=20don=E2=80=99t=20invalidate=20layout=20?= =?utf8?q?upon=20invalid=20'layout=20toggle'=20params=20(#2965)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit fixes #2903 --- src/con.c | 4 +++- testcases/t/292-regress-layout-toggle.t | 29 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 testcases/t/292-regress-layout-toggle.t diff --git a/src/con.c b/src/con.c index 04aacd32..df115230 100644 --- a/src/con.c +++ b/src/con.c @@ -1841,7 +1841,9 @@ void con_toggle_layout(Con *con, const char *toggle_mode) { } } - con_set_layout(con, new_layout); + if (new_layout != L_DEFAULT) { + con_set_layout(con, new_layout); + } } else if (strcasecmp(toggle_mode, "all") == 0 || strcasecmp(toggle_mode, "default") == 0) { if (parent->layout == L_STACKED) con_set_layout(con, L_TABBED); diff --git a/testcases/t/292-regress-layout-toggle.t b/testcases/t/292-regress-layout-toggle.t new file mode 100644 index 00000000..a8fd3a6d --- /dev/null +++ b/testcases/t/292-regress-layout-toggle.t @@ -0,0 +1,29 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Please read the following documents before working on tests: +# • http://build.i3wm.org/docs/testsuite.html +# (or docs/testsuite) +# +# • http://build.i3wm.org/docs/lib-i3test.html +# (alternatively: perldoc ./testcases/lib/i3test.pm) +# +# • http://build.i3wm.org/docs/ipc.html +# (or docs/ipc) +# +# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf +# (unless you are already familiar with Perl) +# +# Regression test: verify layout toggle with invalid parameters does not set +# layout to L_DEFAULT, which crashes i3 upon the next IPC message. +# Ticket: #2903 +# Bug still in: 4.14-87-g607e97e6 +use i3test; + +cmd 'layout toggle 1337 1337'; + +fresh_workspace; + +does_i3_live; + +done_testing; -- 2.39.5