From ab9a36f8c1c9a3d43d56c584767bde2072161408 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 b2820a59c..9623e2a3e 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -1159,27 +1159,20 @@ is_ascii_control_char(char x) { 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 UTF8String]; + _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;