[Bf-blender-cvs] [1fed24de5a3] master: GHOST/Wayland: acquire locks before freeing data on exit
Campbell Barton
noreply at git.blender.org
Thu Jun 16 04:30:26 CEST 2022
Commit: 1fed24de5a38c2133439e78cedc27d265962f90a
Author: Campbell Barton
Date: Thu Jun 16 12:29:22 2022 +1000
Branches: master
https://developer.blender.org/rB1fed24de5a38c2133439e78cedc27d265962f90a
GHOST/Wayland: acquire locks before freeing data on exit
===================================================================
M intern/ghost/intern/GHOST_SystemWayland.cpp
===================================================================
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 15aa379c531..cf5ba550e55 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -263,21 +263,36 @@ static void display_destroy(display_t *d)
}
for (input_t *input : d->inputs) {
- if (input->data_source) {
- free(input->data_source->buffer_out);
- if (input->data_source->data_source) {
- wl_data_source_destroy(input->data_source->data_source);
+
+ /* First handle members that require locking.
+ * While highly unlikely, it's possible they are being used while this function runs. */
+ {
+ std::lock_guard lock{input->data_source_mutex};
+ if (input->data_source) {
+ free(input->data_source->buffer_out);
+ if (input->data_source->data_source) {
+ wl_data_source_destroy(input->data_source->data_source);
+ }
+ delete input->data_source;
}
- delete input->data_source;
}
- if (input->data_offer_dnd) {
- wl_data_offer_destroy(input->data_offer_dnd->id);
- delete input->data_offer_dnd;
+
+ {
+ std::lock_guard lock{input->data_offer_dnd_mutex};
+ if (input->data_offer_dnd) {
+ wl_data_offer_destroy(input->data_offer_dnd->id);
+ delete input->data_offer_dnd;
+ }
}
- if (input->data_offer_copy_paste) {
- wl_data_offer_destroy(input->data_offer_copy_paste->id);
- delete input->data_offer_copy_paste;
+
+ {
+ std::lock_guard lock{input->data_offer_copy_paste_mutex};
+ if (input->data_offer_copy_paste) {
+ wl_data_offer_destroy(input->data_offer_copy_paste->id);
+ delete input->data_offer_copy_paste;
+ }
}
+
if (input->data_device) {
wl_data_device_release(input->data_device);
}
More information about the Bf-blender-cvs
mailing list