fix: crash from appcenter in rare scenario

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
This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-09-08 19:44:35 +09:00
1 parent 6edced005a
commit c49a2bcd4b
2 files changed
+4 -4

No files matched your search

+3 -3
View File
@@ -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)
}
}
+1 -1
View File
@@ -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()