Skip to content

Commit

Permalink
impl drop on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Nov 6, 2023
1 parent 6a6cc96 commit 71b5663
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/webview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ use windows::{
UI::{
Shell::{DefSubclassProc, SHCreateMemStream, SetWindowSubclass},
WindowsAndMessaging::{
self as win32wm, CreateWindowExW, DefWindowProcW, PostMessageW, RegisterClassExW,
RegisterWindowMessageA, SetWindowPos, ShowWindow, CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT,
HCURSOR, HICON, HMENU, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE,
SWP_NOZORDER, SW_HIDE, SW_SHOW, WINDOW_EX_STYLE, WNDCLASSEXW, WS_CHILD, WS_VISIBLE,
self as win32wm, CreateWindowExW, DefWindowProcW, DestroyWindow, PostMessageW,
RegisterClassExW, RegisterWindowMessageA, SetWindowPos, ShowWindow, CS_HREDRAW, CS_VREDRAW,
CW_USEDEFAULT, HCURSOR, HICON, HMENU, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOMOVE,
SWP_NOSIZE, SWP_NOZORDER, SW_HIDE, SW_SHOW, WINDOW_EX_STYLE, WNDCLASSEXW, WS_CHILD,
WS_VISIBLE,
},
},
},
Expand Down Expand Up @@ -63,6 +64,15 @@ pub(crate) struct InnerWebView {
file_drop_controller: Option<FileDropController>,
}

impl Drop for InnerWebView {
fn drop(&mut self) {
let _ = unsafe { self.controller.Close() };
if self.is_child {
let _ = unsafe { DestroyWindow(self.hwnd) };
}
}
}

impl InnerWebView {
pub fn new(
window: &impl HasRawWindowHandle,
Expand Down

0 comments on commit 71b5663

Please sign in to comment.