mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-25 12:38:24 +01:00
Return null from GlfwBackend.GetClipboardText when the clipboard holds no text
glfwGetClipboardString returns NULL when the clipboard cannot be converted to text (GLFW_FORMAT_UNAVAILABLE), and Glfw.Clipboard is declared string? for it. Passing that null to Utf8.GetByteCount threw ArgumentNullException inside the native callback, which ended the process on Ctrl+V. ImGui treats a null clipboard as nothing to paste, as with the C++ imgui_impl_glfw. Fixes #8 Signed-off-by: Laurens de Voogd <laurens@devoogd.be>
This commit is contained in:
parent
ba891e7c62
commit
66b9705837
1 changed files with 3 additions and 0 deletions
|
|
@ -277,6 +277,9 @@ public partial class GlfwBackend : IPlatformBackend
|
|||
private unsafe byte* GetClipboardText(ImGuiContextPtr context)
|
||||
{
|
||||
var str = Glfw.Clipboard;
|
||||
if (str is null)
|
||||
return null;
|
||||
|
||||
var byteCount = Utf8.GetByteCount(str);
|
||||
_cachedClipboardText.Count = byteCount + 1;
|
||||
Utf8.FromUtf16(str, _cachedClipboardText.AsSpan(), out _, out _);
|
||||
|
|
|
|||
Loading…
Reference in a new issue