Merge pull request #3399 from RedSoxFan/fix-output-destruction-segfaults

Fix segfaults on output destruction
This commit is contained in:
emersion 2019-01-10 09:20:07 +01:00 committed by GitHub
commit 9abac85888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -85,6 +85,10 @@ static struct sway_node *node_at_coords(
return NULL; return NULL;
} }
struct sway_output *output = wlr_output->data; struct sway_output *output = wlr_output->data;
if (!output) {
// output is being destroyed
return NULL;
}
double ox = lx, oy = ly; double ox = lx, oy = ly;
wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy); wlr_output_layout_output_coords(root->output_layout, wlr_output, &ox, &oy);

View file

@ -58,6 +58,7 @@ struct sway_output *output_create(struct wlr_output *wlr_output) {
wlr_output->data = output; wlr_output->data = output;
wl_signal_add(&wlr_output->events.destroy, &output->destroy); wl_signal_add(&wlr_output->events.destroy, &output->destroy);
wl_signal_init(&output->events.destroy);
wl_list_insert(&root->all_outputs, &output->link); wl_list_insert(&root->all_outputs, &output->link);
@ -76,7 +77,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
wl_list_init(&output->layers[i]); wl_list_init(&output->layers[i]);
} }
wl_signal_init(&output->events.destroy);
output->enabled = true; output->enabled = true;
list_add(root->outputs, output); list_add(root->outputs, output);