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.
This commit is contained in:
Orestis Floros 2018-04-22 03:48:50 +03:00
parent 5a0f02b7ff
commit 799e3951a2
No known key found for this signature in database
GPG Key ID: E9AD9F32E401E38F
1 changed files with 4 additions and 2 deletions

View File

@ -2373,6 +2373,10 @@ bool con_swap(Con *first, Con *second) {
/* Move first to second. */ /* Move first to second. */
result &= _con_move_to_con(first, second, false, false, false, true, false); 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 /* If we moved the container holding the focused window to another
* workspace we need to ensure the visible workspace has the focused * 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. */ /* Move second to where first has been originally. */
result &= _con_move_to_con(second, fake, false, false, false, true, false); 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) { if (!result) {
goto swap_end; goto swap_end;
} }