aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsterm.m
diff options
context:
space:
mode:
authorPo Lu2022-05-31 16:40:57 +0800
committerPo Lu2022-05-31 16:40:57 +0800
commit7263b10efbfd2f0478e521173e9d657e080e5cff (patch)
tree8047ecb38a6be0e64d8ccd3301dbb5bcd0abdec6 /src/nsterm.m
parentd94890404e91d5ba50afaa4bc27b9c655dbed5f1 (diff)
downloademacs-7263b10efbfd2f0478e521173e9d657e080e5cff.tar.gz
emacs-7263b10efbfd2f0478e521173e9d657e080e5cff.zip
Fix autorelease pool "straddling" during DND on NS
* src/nsterm.m (ns_mouse_position): Implement `drag-source' on NS. ([EmacsView draggingUpdated:]): Add autorelease pool around callbacks. ([EmacsWindow beginDrag:forPasteboard:]): Block input around dragImage.
Diffstat (limited to 'src/nsterm.m')
-rw-r--r--src/nsterm.m33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index 0c83656125c..0f1b5974574 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2297,6 +2297,11 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
2297 struct frame *f = NULL; 2297 struct frame *f = NULL;
2298 struct ns_display_info *dpyinfo; 2298 struct ns_display_info *dpyinfo;
2299 bool return_no_frame_flag = false; 2299 bool return_no_frame_flag = false;
2300#ifdef NS_IMPL_COCOA
2301 NSPoint screen_position;
2302 NSInteger window_number;
2303 NSWindow *w;
2304#endif
2300 2305
2301 NSTRACE ("ns_mouse_position"); 2306 NSTRACE ("ns_mouse_position");
2302 2307
@@ -2323,18 +2328,19 @@ ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
2323 This doesn't work on GNUstep, although in recent versions there 2328 This doesn't work on GNUstep, although in recent versions there
2324 is compatibility code that makes it a noop. */ 2329 is compatibility code that makes it a noop. */
2325 2330
2326 NSPoint screen_position = [NSEvent mouseLocation]; 2331 screen_position = [NSEvent mouseLocation];
2327 NSInteger window_number = 0; 2332 window_number = 0;
2333
2328 do 2334 do
2329 { 2335 {
2330 NSWindow *w; 2336 window_number = [NSWindow windowNumberAtPoint: screen_position
2337 belowWindowWithWindowNumber: window_number];
2338 w = [NSApp windowWithWindowNumber: window_number];
2331 2339
2332 window_number = [NSWindow windowNumberAtPoint:screen_position 2340 if (w && [[w delegate] isKindOfClass: [EmacsView class]])
2333 belowWindowWithWindowNumber:window_number]; 2341 f = ((EmacsView *) [w delegate])->emacsframe;
2334 w = [NSApp windowWithWindowNumber:window_number]; 2342 else if (EQ (track_mouse, Qdrag_source))
2335 2343 break;
2336 if (w && [[w delegate] isKindOfClass:[EmacsView class]])
2337 f = ((EmacsView *)[w delegate])->emacsframe;
2338 } 2344 }
2339 while (window_number > 0 && !f); 2345 while (window_number > 0 && !f);
2340#endif 2346#endif
@@ -8623,6 +8629,12 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
8623#endif 8629#endif
8624 NSPoint position; 8630 NSPoint position;
8625 int x, y; 8631 int x, y;
8632 NSAutoreleasePool *ap;
8633 specpdl_ref count;
8634
8635 ap = [[NSAutoreleasePool alloc] init];
8636 count = SPECPDL_INDEX ();
8637 record_unwind_protect_ptr (ns_release_autorelease_pool, ap);
8626 8638
8627#ifdef NS_IMPL_GNUSTEP 8639#ifdef NS_IMPL_GNUSTEP
8628 EVENT_INIT (ie); 8640 EVENT_INIT (ie);
@@ -8656,6 +8668,7 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
8656 redisplay (); 8668 redisplay ();
8657#endif 8669#endif
8658 8670
8671 unbind_to (count, Qnil);
8659 return NSDragOperationGeneric; 8672 return NSDragOperationGeneric;
8660} 8673}
8661 8674
@@ -9582,6 +9595,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
9582 NSCompositingOperationCopy); 9595 NSCompositingOperationCopy);
9583 [image unlockFocus]; 9596 [image unlockFocus];
9584 9597
9598 block_input ();
9585 if (last_drag_event) 9599 if (last_drag_event)
9586 [self dragImage: image 9600 [self dragImage: image
9587 at: NSMakePoint (0, 0) 9601 at: NSMakePoint (0, 0)
@@ -9590,6 +9604,7 @@ nswindow_orderedIndex_sort (id w1, id w2, void *c)
9590 pasteboard: pasteboard 9604 pasteboard: pasteboard
9591 source: self 9605 source: self
9592 slideBack: NO]; 9606 slideBack: NO];
9607 unblock_input ();
9593 9608
9594 [image release]; 9609 [image release];
9595 9610