From 55b6d31e4ab1a79e4acb7e4d53e531fc1bc9b9da Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 6 Jan 2011 14:35:04 +0100 Subject: [PATCH] =?UTF-8?q?Bugfix:=20randr:=20Don=E2=80=99t=20close=20cont?= =?UTF-8?q?ainer=20if=20it=20was=20not=20initialized=20before?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/randr.c | 56 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/randr.c b/src/randr.c index 26f9102b..43a73442 100644 --- a/src/randr.c +++ b/src/randr.c @@ -534,36 +534,38 @@ void randr_query_outputs() { if ((first = get_first_output()) == NULL) die("No usable outputs available\n"); - /* We need to move the workspaces from the disappearing output to the first output */ - /* 1: Get the con to focus next, if the disappearing ws is focused */ - Con *next = NULL; - if (TAILQ_FIRST(&(croot->focus_head)) == output->con) { - DLOG("This output (%p) was focused! Getting next\n", output->con); - next = con_next_focused(output->con); - DLOG("next = %p\n", next); - } + if (output->con != NULL) { + /* We need to move the workspaces from the disappearing output to the first output */ + /* 1: Get the con to focus next, if the disappearing ws is focused */ + Con *next = NULL; + if (TAILQ_FIRST(&(croot->focus_head)) == output->con) { + DLOG("This output (%p) was focused! Getting next\n", output->con); + next = con_next_focused(output->con); + DLOG("next = %p\n", next); + } - /* 2: iterate through workspaces and re-assign them */ - Con *current; - while (!TAILQ_EMPTY(&(output->con->nodes_head))) { - current = TAILQ_FIRST(&(output->con->nodes_head)); - DLOG("Detaching current = %p / %s\n", current, current->name); - con_detach(current); - DLOG("Re-attaching current = %p / %s\n", current, current->name); - con_attach(current, first->con, false); - DLOG("Done, next\n"); - } - DLOG("re-attached all workspaces\n"); + /* 2: iterate through workspaces and re-assign them */ + Con *current; + while (!TAILQ_EMPTY(&(output->con->nodes_head))) { + current = TAILQ_FIRST(&(output->con->nodes_head)); + DLOG("Detaching current = %p / %s\n", current, current->name); + con_detach(current); + DLOG("Re-attaching current = %p / %s\n", current, current->name); + con_attach(current, first->con, false); + DLOG("Done, next\n"); + } + DLOG("re-attached all workspaces\n"); - if (next) { - DLOG("now focusing next = %p\n", next); - con_focus(next); - } + if (next) { + DLOG("now focusing next = %p\n", next); + con_focus(next); + } - DLOG("destroying disappearing con %p\n", output->con); - tree_close(output->con, false, true); - DLOG("Done. Should be fine now\n"); - output->con = NULL; + DLOG("destroying disappearing con %p\n", output->con); + tree_close(output->con, false, true); + DLOG("Done. Should be fine now\n"); + output->con = NULL; + } output->to_be_disabled = false; }