Fix crash on self drop

This commit is contained in:
Kovid Goyal 2026-02-08 20:43:48 +05:30
parent 625e3b5d1c
commit 08217c949d
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 4 deletions

View file

@ -1721,10 +1721,12 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
bool from_self = ([sender draggingSource] != nil);
_GLFWDropData *d = &window->ns.drop_data;
size_t mime_count = _glfwInputDropEvent(window, GLFW_DROP_DROP, xpos, ypos, d->mimes, d->mimes_count, from_self);
update_drop_state(window, mime_count);
window->ns.drop_data.pasteboard = [[sender draggingPasteboard] retain];
for (size_t i = 0; i < window->ns.drop_data.mimes_count; i++)
_glfwPlatformRequestDropData(window, window->ns.drop_data.mimes[i]);
if (d->mimes) {
update_drop_state(window, mime_count);
window->ns.drop_data.pasteboard = [[sender draggingPasteboard] retain];
for (size_t i = 0; i < d->mimes_count; i++)
_glfwPlatformRequestDropData(window, d->mimes[i]);
}
return YES;
}
@ -2523,6 +2525,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
GLFWWindow *w = window->ns.object;
if (_glfw.ns.disabledCursorWindow == window)
_glfw.ns.disabledCursorWindow = NULL;
free_drop_data(window);
[w orderOut:nil];

1
glfw/wl_window.c vendored
View file

@ -2616,6 +2616,7 @@ drop(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED) {
while (window) {
if (window->wl.surface == offer->surface) {
size_t num_mimes = _glfwInputDropEvent(window, GLFW_DROP_DROP, 0, 0, offer->mimes, offer->mimes_count, offer->is_self_offer);
if (!offer->mimes) { destroy_data_offer(offer); return; }
for (size_t i = 0; i < num_mimes; i++) request_drop_data(offer, offer->mimes[i]);
break;
}