From: Michael Stapelberg Date: Thu, 20 Oct 2011 17:47:09 +0000 (+0100) Subject: Clean bars before reloading the config (+test) X-Git-Tag: 4.1~92^2~34 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ad0f13a0a987c60094d207e8fc43bac4b525f4d1;p=i3%2Fi3 Clean bars before reloading the config (+test) While the configuration gets updated in i3, the i3bar processes will not pick up these changes. We have to think about a good way to do that. --- diff --git a/src/config.c b/src/config.c index d39a5761..0830add8 100644 --- a/src/config.c +++ b/src/config.c @@ -295,6 +295,32 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, FREE(assign); } + /* Clear bar configs */ + Barconfig *barconfig; + while (!TAILQ_EMPTY(&barconfigs)) { + barconfig = TAILQ_FIRST(&barconfigs); + FREE(barconfig->id); + for (int c = 0; c < barconfig->num_outputs; c++) + free(barconfig->outputs[c]); + FREE(barconfig->outputs); + FREE(barconfig->tray_output); + FREE(barconfig->socket_path); + FREE(barconfig->status_command); + FREE(barconfig->font); + FREE(barconfig->colors.background); + FREE(barconfig->colors.statusline); + FREE(barconfig->colors.focused_workspace_text); + FREE(barconfig->colors.focused_workspace_bg); + FREE(barconfig->colors.active_workspace_text); + FREE(barconfig->colors.active_workspace_bg); + FREE(barconfig->colors.inactive_workspace_text); + FREE(barconfig->colors.inactive_workspace_bg); + FREE(barconfig->colors.urgent_workspace_text); + FREE(barconfig->colors.urgent_workspace_bg); + TAILQ_REMOVE(&barconfigs, barconfig, configs); + FREE(barconfig); + } + /* Clear workspace names */ #if 0 Workspace *ws; diff --git a/testcases/t/177-bar-config.t b/testcases/t/177-bar-config.t index c7cf2843..761dbf21 100644 --- a/testcases/t/177-bar-config.t +++ b/testcases/t/177-bar-config.t @@ -54,6 +54,14 @@ ok($bar_config->{workspace_buttons}, 'workspace buttons enabled per default'); is($bar_config->{mode}, 'hide', 'hide mode by default'); is($bar_config->{position}, 'bottom', 'position bottom by default'); +##################################################################### +# ensure that reloading cleans up the old bar configs +##################################################################### + +cmd 'reload'; +$bars = $i3->get_bar_config()->recv; +is(@$bars, 1, 'still one bar configured'); + exit_gracefully($pid); #####################################################################