Skip to content

Commit 2eccec6

Browse files
committed
Don't panic if HWND is invalid in OsWindow drop()
1 parent cb258b6 commit 2eccec6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

plugin-canvas/src/platform/win32/window.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,12 @@ impl Drop for OsWindow {
305305

306306
unsafe {
307307
SetWindowLongPtrW(self.hwnd(), GWLP_USERDATA, 0);
308-
RevokeDragDrop(self.hwnd()).unwrap();
309-
DestroyWindow(self.hwnd()).unwrap();
310-
UnregisterClassW(PCWSTR(self.window_class as _), Some(PLUGIN_HINSTANCE.with(|hinstance| *hinstance))).unwrap();
308+
309+
// Allow these to fail since we're in Drop
310+
// When the plugin instance has been deleted, the HWND might not be valid anymore
311+
RevokeDragDrop(self.hwnd()).ok();
312+
DestroyWindow(self.hwnd()).ok();
313+
UnregisterClassW(PCWSTR(self.window_class as _), Some(PLUGIN_HINSTANCE.with(|hinstance| *hinstance))).ok();
311314
}
312315
}
313316
}

0 commit comments

Comments
 (0)