Skip to content

Commit

Permalink
fix: crash from appcenter in rare scenario
Browse files Browse the repository at this point in the history
Stack trace:

closure #1 () -> () in AltTab.(windowDestroyed in _3E1A2D100A6A10BAACF80B17AC9C41B5)(__C.AXUIElementRef) throws -> () Windows.swift:43
reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () <compiler-generated>:0
  • Loading branch information
lwouis committed Sep 8, 2020
1 parent 6edced0 commit c49a2bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/logic/Windows.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ class Windows {
return targetIndex
}

static func moveFocusedWindowIndexAfterWindowDestroyedInBackground(_ destroyedWindowIndex: Int) {
if focusedWindowIndex > destroyedWindowIndex {
static func moveFocusedWindowIndexAfterWindowDestroyedInBackground(_ window: Window) {
if focusedWindowIndex > window.lastFocusOrder {
cycleFocusedWindowIndex(-1)
} else if focusedWindowIndex == destroyedWindowIndex && !focusedWindow()!.shouldShowTheUser {
} else if focusedWindowIndex == window.lastFocusOrder && !window.shouldShowTheUser {
cycleFocusedWindowIndex(1)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/logic/events/AccessibilityEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private func windowDestroyed(_ element: AXUIElement) throws {
Windows.removeAndUpdateFocus(window)
let windowlessApp = window.application.addWindowslessAppsIfNeeded()
if Windows.list.count > 0 {
Windows.moveFocusedWindowIndexAfterWindowDestroyedInBackground(window.lastFocusOrder)
Windows.moveFocusedWindowIndexAfterWindowDestroyedInBackground(window)
App.app.refreshOpenUi(windowlessApp)
} else {
App.app.hideUi()
Expand Down

0 comments on commit c49a2bc

Please sign in to comment.