aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/output.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 03:07:36 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-01-10 03:07:36 -0500
commit8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e (patch)
treee15d1e5a343750dc48c1055e55472641b5fda487 /sway/tree/output.c
parentReset container dimensions when moving into workspace from direction (diff)
downloadsway-8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e.tar.gz
sway-8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e.tar.zst
sway-8fd3f32c79c4784d846e05f5d9b4f284cd10ae2e.zip
Fix segfaults on output destruction
This fixes two causes of segfaulting when an output is destroyed. The first occurred when an output was never enabled. The issue was that the destroy signal was never initialized so when it was emitted, sway segfaulted. This was fixed by moving the initialization into `output_create` since all outputs, regardless of whether they have ever been enabled, will be destroyed at some point. The second occurred when the cursor was on an output that was being destroyed. The sway output would have already been removed, but if there are other outputs, a cursor rebase would still occur. Since the wlr_output still existed and the sway output was destroyed, the cursor could be over nothing, resulting in a segfault when trying to get the sway output, which was destroyed.
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r--sway/tree/output.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 95ab9378..f24be010 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -58,6 +58,7 @@ struct sway_output *output_create(struct wlr_output *wlr_output) {
58 wlr_output->data = output; 58 wlr_output->data = output;
59 59
60 wl_signal_add(&wlr_output->events.destroy, &output->destroy); 60 wl_signal_add(&wlr_output->events.destroy, &output->destroy);
61 wl_signal_init(&output->events.destroy);
61 62
62 wl_list_insert(&root->all_outputs, &output->link); 63 wl_list_insert(&root->all_outputs, &output->link);
63 64
@@ -76,7 +77,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
76 for (size_t i = 0; i < len; ++i) { 77 for (size_t i = 0; i < len; ++i) {
77 wl_list_init(&output->layers[i]); 78 wl_list_init(&output->layers[i]);
78 } 79 }
79 wl_signal_init(&output->events.destroy);
80 80
81 output->enabled = true; 81 output->enabled = true;
82 list_add(root->outputs, output); 82 list_add(root->outputs, output);