summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2023-03-06 13:15:13 +0100
committerRay <[email protected]>2023-03-06 13:15:13 +0100
commitcf1ebada0e0c18a02d48f091091418ce7b020b1e (patch)
tree9b3617db766c0b0b0e0a276641e0b0127e111af4 /src
parentaae7ab64c7a6b4e7e040b21736710843086b35a0 (diff)
downloadraylib-cf1ebada0e0c18a02d48f091091418ce7b020b1e.tar.gz
raylib-cf1ebada0e0c18a02d48f091091418ce7b020b1e.zip
Tweak `WindowDropCallback()` #2943
Diffstat (limited to 'src')
-rw-r--r--src/rcore.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 4f3d98b0..071915cf 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -5598,25 +5598,28 @@ static void CursorEnterCallback(GLFWwindow *window, int enter)
// GLFW3 Window Drop Callback, runs when drop files into window
static void WindowDropCallback(GLFWwindow *window, int count, const char **paths)
{
- // In case previous dropped filepaths have not been freed, we free them
- if (CORE.Window.dropFileCount > 0)
+ if (count > 0)
{
- for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
+ // In case previous dropped filepaths have not been freed, we free them
+ if (CORE.Window.dropFileCount > 0)
+ {
+ for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++) RL_FREE(CORE.Window.dropFilepaths[i]);
- RL_FREE(CORE.Window.dropFilepaths);
+ RL_FREE(CORE.Window.dropFilepaths);
- CORE.Window.dropFileCount = 0;
- CORE.Window.dropFilepaths = NULL;
- }
+ CORE.Window.dropFileCount = 0;
+ CORE.Window.dropFilepaths = NULL;
+ }
- // WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
- CORE.Window.dropFileCount = count;
- CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
+ // WARNING: Paths are freed by GLFW when the callback returns, we must keep an internal copy
+ CORE.Window.dropFileCount = count;
+ CORE.Window.dropFilepaths = (char **)RL_CALLOC(CORE.Window.dropFileCount, sizeof(char *));
- for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++)
- {
- CORE.Window.dropFilepaths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
- strcpy(CORE.Window.dropFilepaths[i], paths[i]);
+ for (unsigned int i = 0; i < CORE.Window.dropFileCount; i++)
+ {
+ CORE.Window.dropFilepaths[i] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
+ strcpy(CORE.Window.dropFilepaths[i], paths[i]);
+ }
}
}
#endif