From 3a90c7a04509a59a112e81dbf4cc2d58945ec70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Capello?= Date: Tue, 3 Sep 2024 10:49:57 -0300 Subject: [PATCH 1/2] [osx] Fix as_nsdragoperation function The variable used as the return value of the function had an undefined initial value which lead to unpredictable return values. Also took the chance to refactor the initial value of the variable used in as_dropoperation --- os/osx/dnd.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/osx/dnd.mm b/os/osx/dnd.mm index f65afae33..f7e6b4a38 100644 --- a/os/osx/dnd.mm +++ b/os/osx/dnd.mm @@ -72,7 +72,7 @@ NSDragOperation as_nsdragoperation(const os::DropOperation op) { - NSDragOperation nsdop; + NSDragOperation nsdop = NSDragOperationNone; if (static_cast(op) & static_cast(os::DropOperation::Copy)) nsdop |= NSDragOperationCopy; @@ -87,7 +87,7 @@ NSDragOperation as_nsdragoperation(const os::DropOperation op) os::DropOperation as_dropoperation(const NSDragOperation nsdop) { - int op = 0; + int op = static_cast(os::DropOperation::None); if (nsdop & NSDragOperationCopy) op |= static_cast(os::DropOperation::Copy); From fc919ecf74d915478df97100c20b896ef5129c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Capello?= Date: Tue, 3 Sep 2024 10:52:36 -0300 Subject: [PATCH 2/2] [win] Refactor as_dropoperation function Refactors the initial value of the variable used in as_dropoperation to use a static cast of the enum value instead of 0. --- os/win/dnd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/win/dnd.cpp b/os/win/dnd.cpp index 4f3b8002f..5af81407e 100644 --- a/os/win/dnd.cpp +++ b/os/win/dnd.cpp @@ -33,7 +33,7 @@ DWORD as_dropeffect(const os::DropOperation op) os::DropOperation as_dropoperation(DWORD pdwEffect) { - int op = 0; + int op = static_cast(os::DropOperation::None); if (pdwEffect & DROPEFFECT_COPY) op |= static_cast(os::DropOperation::Copy);