fix: prevent crash when sending a debug profile

This commit is contained in:
lwouis committed 2025-12-07 23:45:42 +01:00
1 parent 6426d318fb
commit 741e7902db
1 file changed
+8 -5
+8 -5
View File
@@ -106,11 +106,14 @@ class DebugProfile {
}
static func inputSource() -> String {
if let inputSource = TISCopyCurrentKeyboardInputSource()?.takeUnretainedValue(),
let localizedNamePointer = TISGetInputSourceProperty(inputSource, kTISPropertyLocalizedName) {
let localizedName = Unmanaged<AnyObject>.fromOpaque(localizedNamePointer).takeUnretainedValue()
return localizedName as? String ?? ""
let r = DispatchQueue.main.sync {
if let inputSource = TISCopyCurrentKeyboardInputSource()?.takeUnretainedValue(),
let localizedNamePointer = TISGetInputSourceProperty(inputSource, kTISPropertyLocalizedName) {
let localizedName = Unmanaged<AnyObject>.fromOpaque(localizedNamePointer).takeUnretainedValue()
return localizedName as? String ?? ""
}
return ""
}
return ""
return r
}
}