aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-08 19:28:53 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-08 19:28:53 +1000
commit82423991a8512ab97fbc41d1e190e709c58bc346 (patch)
tree837e45f94240e02e2ab0f8f931227943e00819b3 /sway/config.c
parentMerge pull request #2786 from swaywm/no-op-client-commands (diff)
downloadsway-82423991a8512ab97fbc41d1e190e709c58bc346.tar.gz
sway-82423991a8512ab97fbc41d1e190e709c58bc346.tar.zst
sway-82423991a8512ab97fbc41d1e190e709c58bc346.zip
Reload config using idle event
This patch makes it so when you run reload, the actual reloading is deferred to the next time the event loop becomes idle. This avoids several use-after-frees and removes the workarounds we have to avoid them. When you run reload, we validate the config before creating the idle event. This is so the reload command will still return an error if there are validation errors. To allow this, load_main_config has been adjusted so it doesn't apply the config if validating is true rather than applying it unconditionally. This also fixes a memory leak in the reload command where if the config failed to load, the bar_ids list would not be freed.
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sway/config.c b/sway/config.c
index b56c4f71..8f8ed438 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -457,6 +457,12 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
457 success = success && load_config(path, config, 457 success = success && load_config(path, config,
458 &config->swaynag_config_errors); 458 &config->swaynag_config_errors);
459 459
460 if (validating) {
461 free_config(config);
462 config = old_config;
463 return success;
464 }
465
460 if (is_active) { 466 if (is_active) {
461 for (int i = 0; i < config->output_configs->length; i++) { 467 for (int i = 0; i < config->output_configs->length; i++) {
462 apply_output_config_to_outputs(config->output_configs->items[i]); 468 apply_output_config_to_outputs(config->output_configs->items[i]);