]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix race conditions when calculating Haiku frame geometry
authorPo Lu <luangruo@yahoo.com>
Wed, 18 May 2022 04:07:31 +0000 (04:07 +0000)
committerPo Lu <luangruo@yahoo.com>
Wed, 18 May 2022 04:07:31 +0000 (04:07 +0000)
* src/haiku_support.cc (be_lock_window, be_unlock_window): New
functions.
* src/haiku_support.h: Update prototypes.

* src/haikufns.c (frame_geometry): Lock window before asking for
its dimensions and frame.

src/haiku_support.cc
src/haiku_support.h
src/haikufns.c

index 28c86085847d9b9db9cf11da8cdb9b2103224efd..0c126dab3d6da6cacd1d2bf831be553ff42b1058 100644 (file)
@@ -5163,3 +5163,20 @@ be_send_move_frame_event (void *window)
 
   msg.SendMessage (SEND_MOVE_FRAME_EVENT);
 }
+
+void
+be_lock_window (void *window)
+{
+  BWindow *wnd = (BWindow *) window;
+
+  if (!wnd->LockLooper ())
+    gui_abort ("Failed to lock window looper");
+}
+
+void
+be_unlock_window (void *window)
+{
+  BWindow *wnd = (BWindow *) window;
+
+  wnd->UnlockLooper ();
+}
index 22f13c1ee67ca17712976c23e69a980c1429680b..14dd36e275a72b39b66222fe8a50babf1c5dc8e5 100644 (file)
@@ -691,6 +691,8 @@ extern void be_get_window_decorator_dimensions (void *, int *, int *, int *, int
 extern void be_get_window_decorator_frame (void *, int *, int *, int *, int *);
 extern void be_send_move_frame_event (void *);
 
+extern void be_lock_window (void *);
+extern void be_unlock_window (void *);
 #ifdef __cplusplus
 }
 
index fa47da73d2c1573993afb1639206df4f73150636..8b6296e6ae12b1e0d59ad07faad975af9d63fe84 100644 (file)
@@ -1394,17 +1394,22 @@ static Lisp_Object
 frame_geometry (Lisp_Object frame, Lisp_Object attribute)
 {
   struct frame *f, *parent;
+  void *window;
   int outer_x, outer_y, outer_width, outer_height;
   int right_off, bottom_off, top_off;
   int native_x, native_y;
 
   f = decode_window_system_frame (frame);
   parent = FRAME_PARENT_FRAME (f);
+  window = FRAME_HAIKU_WINDOW (f);
+
+  be_lock_window (window);
+  be_get_window_decorator_frame (window, &outer_x, &outer_y,
+                                &outer_width, &outer_height);
+  be_get_window_decorator_dimensions (window, NULL, &top_off,
+                                     &right_off, &bottom_off);
+  be_unlock_window (window);
 
-  be_get_window_decorator_frame (FRAME_HAIKU_WINDOW (f), &outer_x,
-                                &outer_y, &outer_width, &outer_height);
-  be_get_window_decorator_dimensions (FRAME_HAIKU_WINDOW (f), NULL,
-                                     &top_off, &right_off, &bottom_off);
   native_x = FRAME_OUTPUT_DATA (f)->frame_x;
   native_y = FRAME_OUTPUT_DATA (f)->frame_y;