From 287f1bffb30ea7d6d7f0f7f6be418dafb6e93503 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 19 Mar 2020 13:34:15 +0530 Subject: [PATCH] Port cocoa backend to use new drop API --- glfw/cocoa_window.m | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index b2820a59cfa..6cb4772ebe1 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1159,27 +1159,20 @@ - (BOOL)performDragOperation:(id )sender const NSUInteger count = [objs count]; if (count) { - char** paths = calloc(count, sizeof(char*)); - for (NSUInteger i = 0; i < count; i++) { id obj = objs[i]; if ([obj isKindOfClass:[NSURL class]]) { - paths[i] = _glfw_strdup([obj fileSystemRepresentation]); + const char *path = [obj fileSystemRepresentation]; + _glfwInputDrop(window, "text/uri-list", path, strlen(path)); } else if ([obj isKindOfClass:[NSString class]]) { - paths[i] = _glfw_strdup([obj UTF8String]); + const char *text = [obj fileSystemRepresentation]; + _glfwInputDrop(window, "text/plain;charset=utf-8", text, strlen(text)); } else { _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Object is neither a URL nor a string"); - paths[i] = _glfw_strdup(""); } } - - _glfwInputDrop(window, (int) count, (const char**) paths); - - for (NSUInteger i = 0; i < count; i++) - free(paths[i]); - free(paths); } return YES;