[Bf-blender-cvs] [b544d989d15] master: GHOST/Wayland: unlock clipboard mutex on failure

Campbell Barton noreply at git.blender.org
Fri Oct 28 02:16:38 CEST 2022


Commit: b544d989d1535705cfd77312829bf6d09394ea5f
Author: Campbell Barton
Date:   Fri Oct 28 09:29:00 2022 +1100
Branches: master
https://developer.blender.org/rBb544d989d1535705cfd77312829bf6d09394ea5f

GHOST/Wayland: unlock clipboard mutex on failure

When the Wayland pipe can't be opened, don't leave the mutex locked.
Also skip checking wl_data_device_manager when reading from the primary
clipboard.

===================================================================

M	intern/ghost/intern/GHOST_SystemWayland.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 0f609395124..36894807e73 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1681,6 +1681,9 @@ static const char *read_buffer_from_data_offer(GWL_DataOffer *data_offer,
   int pipefd[2];
   if (UNLIKELY(pipe(pipefd) != 0)) {
     CLOG_WARN(LOG, "error creating pipe: %s", std::strerror(errno));
+    if (mutex) {
+      mutex->unlock();
+    }
     return nullptr;
   }
   wl_data_offer_receive(data_offer->id, mime_receive, pipefd[1]);
@@ -1707,6 +1710,9 @@ static const char *read_buffer_from_primary_selection_offer(
   int pipefd[2];
   if (UNLIKELY(pipe(pipefd) != 0)) {
     CLOG_WARN(LOG, "error creating pipe: %s", std::strerror(errno));
+    if (mutex) {
+      mutex->unlock();
+    }
     return nullptr;
   }
   zwp_primary_selection_offer_v1_receive(data_offer->id, mime_receive, pipefd[1]);
@@ -5114,6 +5120,9 @@ static void system_clipboard_put_primary_selection(GWL_Display *display, const c
 
 static void system_clipboard_put(GWL_Display *display, const char *buffer)
 {
+  if (!display->wl_data_device_manager) {
+    return;
+  }
   GWL_Seat *seat = display->seats[0];
 
   std::lock_guard lock{seat->data_source_mutex};
@@ -5140,7 +5149,7 @@ static void system_clipboard_put(GWL_Display *display, const char *buffer)
 
 void GHOST_SystemWayland::putClipboard(const char *buffer, bool selection) const
 {
-  if (UNLIKELY(!display_->wl_data_device_manager || display_->seats.empty())) {
+  if (UNLIKELY(display_->seats.empty())) {
     return;
   }



More information about the Bf-blender-cvs mailing list