Skip to content

Commit

Permalink
fix: apps would not quit properly sometimes (regression from 10b2c71)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Sep 4, 2020
1 parent 657c9e5 commit 41384d9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/logic/Applications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ class Applications {
static func removeRunningApplications(_ runningApps: [NSRunningApplication]) {
var windowsOnTheLeftOfFocusedWindow = 0
for runningApp in runningApps {
Applications.list.removeAll(where: { $0.pid == runningApp.processIdentifier })
// comparing pid here can fail here, as it can be already nil; we use isEqual here to avoid the issue
Applications.list.removeAll(where: { $0.runningApplication.isEqual(runningApp) })
Windows.list.enumerated().forEach { (index, window) in
if window.application.pid == runningApp.processIdentifier && index < Windows.focusedWindowIndex {
if window.application.runningApplication.isEqual(runningApp) && index < Windows.focusedWindowIndex {
windowsOnTheLeftOfFocusedWindow += 1
}
}
Windows.list.removeAll(where: { $0.application.pid == runningApp.processIdentifier })
Windows.list.removeAll(where: { $0.application.runningApplication.isEqual(runningApp) })
}
guard Windows.list.count > 0 else { App.app.hideUi(); return }
if windowsOnTheLeftOfFocusedWindow > 0 {
Expand Down

0 comments on commit 41384d9

Please sign in to comment.