Skip to content

Commit 1c85625

Browse files
committed
Fix bug causing nonexistent windows to remain in workspace trees.
Previously, when registering window observers fails, the `window.garbageCollect()` call would be a no-op because the window is not in `allWindowsMap`. This would lead to such windows being left bound to the workspace tree, since binding happens inside the window initializer.
1 parent 46b5f5e commit 1c85625

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/AppBundle/tree/MacWindow.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,21 @@ final class MacWindow: Window {
3333
app
3434
)
3535
let window = MacWindow(id, app, axWindow, parent: data.parent, adaptiveWeight: data.adaptiveWeight, index: data.index)
36+
allWindowsMap[id] = window
3637

3738
if window.observe(refreshObs, kAXUIElementDestroyedNotification) &&
3839
window.observe(refreshObs, kAXWindowDeminiaturizedNotification) &&
3940
window.observe(refreshObs, kAXWindowMiniaturizedNotification) &&
4041
window.observe(movedObs, kAXMovedNotification) &&
4142
window.observe(resizedObs, kAXResizedNotification)
4243
{
43-
allWindowsMap[id] = window
4444
debugWindowsIfRecording(window)
4545
if !restoreClosedWindowsCacheIfNeeded(newlyDetectedWindow: window) {
4646
tryOnWindowDetected(window, startup: startup)
4747
}
4848
return window
4949
} else {
50+
// Removes `window` from `allWindowsMap`.
5051
window.garbageCollect(skipClosedWindowsCache: true)
5152
return nil
5253
}

0 commit comments

Comments
 (0)