From 41384d9066f64fe212b3ad06a14d4cd98c890682 Mon Sep 17 00:00:00 2001 From: Louis Pontoise Date: Thu, 3 Sep 2020 18:07:40 +0900 Subject: [PATCH] fix: apps would not quit properly sometimes (regression from 10b2c71) --- src/logic/Applications.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/logic/Applications.swift b/src/logic/Applications.swift index 9b5c4b1c..5569a40e 100644 --- a/src/logic/Applications.swift +++ b/src/logic/Applications.swift @@ -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 {