From 799e3951a2fbf71ae6d8a584e13295e7495cc03b Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 22 Apr 2018 03:48:50 +0300 Subject: [PATCH 1/1] con_swap: exit when first _con_move_to_con fails This is enough to fix the crash discussed in #3259 even though the next commit can fix it independently. This commit is useful because it generally makes sense to abort the command when the first call to _con_move_to_con fails. --- src/con.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/con.c b/src/con.c index deb65558..b7168d41 100644 --- a/src/con.c +++ b/src/con.c @@ -2373,6 +2373,10 @@ bool con_swap(Con *first, Con *second) { /* Move first to second. */ result &= _con_move_to_con(first, second, false, false, false, true, false); + /* If swapping the containers didn't work we don't need to mess with the focus. */ + if (!result) { + goto swap_end; + } /* If we moved the container holding the focused window to another * workspace we need to ensure the visible workspace has the focused @@ -2385,8 +2389,6 @@ bool con_swap(Con *first, Con *second) { /* Move second to where first has been originally. */ result &= _con_move_to_con(second, fake, false, false, false, true, false); - - /* If swapping the containers didn't work we don't need to mess with the focus. */ if (!result) { goto swap_end; } -- 2.39.2