Remove remaining wl_signal_emit calls

Replace them with wlr_signal_emit_safe, which correctly handles
cases where a listener removes another listener.

Reported-by: Isaac Freund <ifreund@ifreund.xyz>
This commit is contained in:
Simon Ser 2022-06-05 09:44:55 +02:00 committed by Benjamin Tissoires
parent 808e660291
commit 99f63b03e7
4 changed files with 16 additions and 13 deletions

View file

@ -14,6 +14,7 @@
#include "render/allocator/drm_dumb.h" #include "render/allocator/drm_dumb.h"
#include "render/allocator/shm.h" #include "render/allocator/shm.h"
#include "render/wlr_renderer.h" #include "render/wlr_renderer.h"
#include "util/signal.h"
#if WLR_HAS_GBM_ALLOCATOR #if WLR_HAS_GBM_ALLOCATOR
#include "render/allocator/gbm.h" #include "render/allocator/gbm.h"
@ -158,7 +159,7 @@ void wlr_allocator_destroy(struct wlr_allocator *alloc) {
if (alloc == NULL) { if (alloc == NULL) {
return; return;
} }
wl_signal_emit(&alloc->events.destroy, NULL); wlr_signal_emit_safe(&alloc->events.destroy, NULL);
alloc->impl->destroy(alloc); alloc->impl->destroy(alloc);
} }

View file

@ -2,7 +2,6 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#endif #endif
#include "tablet-unstable-v2-protocol.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <types/wlr_tablet_v2.h> #include <types/wlr_tablet_v2.h>
@ -12,6 +11,8 @@
#include <wlr/types/wlr_tablet_pad.h> #include <wlr/types/wlr_tablet_pad.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h"
#include "tablet-unstable-v2-protocol.h"
static const struct wlr_tablet_pad_v2_grab_interface default_pad_grab_interface; static const struct wlr_tablet_pad_v2_grab_interface default_pad_grab_interface;
@ -51,7 +52,7 @@ static void handle_tablet_pad_ring_v2_set_feedback(struct wl_client *client,
.index = aux->index .index = aux->index
}; };
wl_signal_emit(&aux->pad->pad->events.ring_feedback, &evt); wlr_signal_emit_safe(&aux->pad->pad->events.ring_feedback, &evt);
} }
static void handle_tablet_pad_ring_v2_destroy(struct wl_client *client, static void handle_tablet_pad_ring_v2_destroy(struct wl_client *client,
@ -89,7 +90,7 @@ static void handle_tablet_pad_strip_v2_set_feedback(struct wl_client *client,
.index = aux->index .index = aux->index
}; };
wl_signal_emit(&aux->pad->pad->events.strip_feedback, &evt); wlr_signal_emit_safe(&aux->pad->pad->events.strip_feedback, &evt);
} }
static void handle_tablet_pad_strip_v2_destroy(struct wl_client *client, static void handle_tablet_pad_strip_v2_destroy(struct wl_client *client,
@ -116,7 +117,7 @@ static void handle_tablet_pad_v2_set_feedback( struct wl_client *client,
.description = description, .description = description,
}; };
wl_signal_emit(&pad->pad->events.button_feedback, &evt); wlr_signal_emit_safe(&pad->pad->events.button_feedback, &evt);
} }
static const struct zwp_tablet_pad_v2_interface tablet_pad_impl = { static const struct zwp_tablet_pad_v2_interface tablet_pad_impl = {

View file

@ -2,9 +2,6 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#endif #endif
#include "tablet-unstable-v2-protocol.h"
#include "util/array.h"
#include "util/time.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <types/wlr_tablet_v2.h> #include <types/wlr_tablet_v2.h>
@ -13,6 +10,10 @@
#include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_v2.h> #include <wlr/types/wlr_tablet_v2.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/array.h"
#include "util/signal.h"
#include "util/time.h"
#include "tablet-unstable-v2-protocol.h"
static const struct wlr_tablet_tool_v2_grab_interface default_tool_grab_interface; static const struct wlr_tablet_tool_v2_grab_interface default_tool_grab_interface;
@ -46,7 +47,7 @@ static void handle_tablet_tool_v2_set_cursor(struct wl_client *client,
.seat_client = tool->seat->seat_client, .seat_client = tool->seat->seat_client,
}; };
wl_signal_emit(&tool->tool->events.set_cursor, &evt); wlr_signal_emit_safe(&tool->tool->events.set_cursor, &evt);
} }
static void handle_tablet_tool_v2_destroy(struct wl_client *client, static void handle_tablet_tool_v2_destroy(struct wl_client *client,

View file

@ -64,7 +64,7 @@ void wlr_buffer_unlock(struct wlr_buffer *buffer) {
buffer->n_locks--; buffer->n_locks--;
if (buffer->n_locks == 0) { if (buffer->n_locks == 0) {
wl_signal_emit(&buffer->events.release, NULL); wlr_signal_emit_safe(&buffer->events.release, NULL);
} }
buffer_consider_destroy(buffer); buffer_consider_destroy(buffer);