From: Orestis Floros Date: Sun, 22 Apr 2018 00:48:50 +0000 (+0300) Subject: con_swap: exit when first _con_move_to_con fails X-Git-Tag: 4.16~90^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=799e3951a2fbf71ae6d8a584e13295e7495cc03b;hp=5a0f02b7ff310f1b928ad4f8bc841b2ed51ab166;p=i3%2Fi3 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. --- 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; }