gpui Windows: no calls on destroyed windows, no deferred report after close

The window procedure records WM_DESTROY, revokes drag-drop while the
handle is valid and drops the activation callback; Drop leaves a
destroyed window alone. A dispatch after quit logs at debug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-10 20:15:53 -04:00
1 parent 09479941ff
commit 3466f108c4
6 files changed
+28 -10

No files matched your search

+8 -5
View File
@@ -62,6 +62,7 @@ pub struct WindowsWindowState {
pub last_reported_capslock: Cell<Option<Capslock>>,
pub hovered: Cell<bool>,
pub last_visibility: Cell<Option<WindowVisibility>>,
pub destroyed: Cell<bool>,
pub direct_manipulation: DirectManipulationHandler,
pub renderer: RefCell<DirectXRenderer>,
@@ -177,6 +178,7 @@ impl WindowsWindowState {
last_reported_capslock: Cell::new(last_reported_capslock),
hovered: Cell::new(hovered),
last_visibility: Cell::new(None),
destroyed: Cell::new(false),
renderer: RefCell::new(renderer),
force_render_pending: Cell::new(false),
click_state,
@@ -610,10 +612,14 @@ impl rwh::HasDisplayHandle for WindowsWindow {
impl Drop for WindowsWindow {
fn drop(&mut self) {
self.0.dialog_owner.close();
unsafe { ShowWindowAsync(self.0.hwnd, SW_HIDE).ok().log_err() };
// `DestroyWindow` below sends `WM_SHOWWINDOW`; without a callback the
// resulting visibility report has nothing to notify.
self.0.state.callbacks.visibility_change.take();
// Windows already destroyed it.
if self.0.state.destroyed.get() {
return;
}
unsafe { ShowWindowAsync(self.0.hwnd, SW_HIDE).ok().log_err() };
// clone this `Rc` to prevent early release of the pointer
let this = self.0.clone();
self.0
@@ -621,10 +627,7 @@ impl Drop for WindowsWindow {
.spawn(async move {
this.dialog_owner.when_idle().await;
let handle = this.hwnd;
unsafe {
RevokeDragDrop(handle).log_err();
DestroyWindow(handle).log_err();
}
unsafe { DestroyWindow(handle).log_err() };
})
.detach();
}