fix: crash when windows changed between the CG and the AX calls
This commit is contained in:
1 parent
6f613547c4
commit
2fa140f027
1 file changed
+6
-3
@@ -131,9 +131,12 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol
|
|||||||
let cgTitle = String(cgWindow[kCGWindowName] as! NSString)
|
let cgTitle = String(cgWindow[kCGWindowName] as! NSString)
|
||||||
let cgOwnerPid = cgWindow[kCGWindowOwnerPID] as! pid_t
|
let cgOwnerPid = cgWindow[kCGWindowOwnerPID] as! pid_t
|
||||||
let i = pidAndCurrentIndex.index(forKey: cgOwnerPid)
|
let i = pidAndCurrentIndex.index(forKey: cgOwnerPid)
|
||||||
pidAndCurrentIndex[cgOwnerPid] = i == nil ? 0 : pidAndCurrentIndex[i!].value + 1
|
pidAndCurrentIndex[cgOwnerPid] = (i == nil ? 0 : pidAndCurrentIndex[i!].value + 1)
|
||||||
let axWindow = axWindows(cgOwnerPid)[pidAndCurrentIndex[cgOwnerPid]!]
|
let axWindow = axWindows(cgOwnerPid)
|
||||||
openWindows.append(OpenWindow(target: axWindow, ownerPid: cgOwnerPid, cgId: cgId, cgTitle: cgTitle))
|
// windows may have changed between the CG and the AX calls
|
||||||
|
if axWindow.count > pidAndCurrentIndex[cgOwnerPid]! {
|
||||||
|
openWindows.append(OpenWindow(target: axWindow[pidAndCurrentIndex[cgOwnerPid]!], ownerPid: cgOwnerPid, cgId: cgId, cgTitle: cgTitle))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user