From 30a85f31141839a5284b1bfdd52b1cb690fcd10d Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Thu, 14 Dec 2023 05:06:18 +0200 Subject: [PATCH] fix(windows): fix file drop handler (#1122) --- .changes/windows-drag-drop.md | 5 +++++ src/webview2/mod.rs | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changes/windows-drag-drop.md diff --git a/.changes/windows-drag-drop.md b/.changes/windows-drag-drop.md new file mode 100644 index 000000000..ca9db563e --- /dev/null +++ b/.changes/windows-drag-drop.md @@ -0,0 +1,5 @@ +--- +"wry": "patch" +--- + +On Windows, fix file drop handler. diff --git a/src/webview2/mod.rs b/src/webview2/mod.rs index cdb53bd4a..aab68b5f4 100644 --- a/src/webview2/mod.rs +++ b/src/webview2/mod.rs @@ -176,15 +176,15 @@ impl InnerWebView { ) -> Result { let _ = unsafe { CoInitializeEx(None, COINIT_APARTMENTTHREADED) }; - let file_drop_controller = attributes - .file_drop_handler - .take() - .map(|handler| FileDropController::new(hwnd, handler)); + let file_drop_handler = attributes.file_drop_handler.take(); let env = Self::create_environment(&web_context, pl_attrs.clone(), &attributes)?; let controller = Self::create_controller(hwnd, &env, attributes.incognito)?; let webview = Self::init_webview(hwnd, attributes, &env, &controller, pl_attrs)?; + let file_drop_controller = + file_drop_handler.map(|handler| FileDropController::new(hwnd, handler)); + Ok(Self { hwnd, controller,