From 65d719a058a0b296feb7de7361422c5339fc11dd Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Tue, 27 Nov 2018 09:53:36 -0500 Subject: [PATCH] Allow DropEvent users to access UTF8_ToManaged --- src/SDL2.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 236a5a3..67f0f40 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -54,7 +54,8 @@ namespace SDL2 return System.Text.Encoding.UTF8.GetBytes(s + '\0'); } - internal static unsafe string UTF8_ToManaged(IntPtr s, bool freePtr = false) + /* This is public because SDL_DropEvent needs it! */ + public static unsafe string UTF8_ToManaged(IntPtr s, bool freePtr = false) { if (s == IntPtr.Zero) { @@ -3967,7 +3968,12 @@ namespace SDL2 { public SDL_EventType type; public UInt32 timestamp; - public IntPtr file; /* char* filename, to be freed */ + + /* char* filename, to be freed. + * Access the variable EXACTLY ONCE like this: + * string s = SDL.UTF8_ToManaged(evt.drop.file, true); + */ + public IntPtr file; } [StructLayout(LayoutKind.Sequential)]