Repo // Add fail-safe for errors related to IMKCandidate internal APIs.
This commit is contained in:
parent
526be1e678
commit
ab724fe680
|
@ -48,19 +48,37 @@ public extension AppDelegate {
|
|||
|
||||
func applicationDidFinishLaunching(_: Notification) {
|
||||
NSUserNotificationCenter.default.delegate = self
|
||||
|
||||
if PrefMgr.shared.failureFlagForIMKCandidates {
|
||||
DispatchQueue.main.async {
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = false
|
||||
PrefMgr.shared.useIMKCandidateWindow = false
|
||||
let userNotification = NSUserNotification()
|
||||
userNotification.title = NSLocalizedString("vChewing", comment: "")
|
||||
userNotification.informativeText = NSLocalizedString(
|
||||
"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments.",
|
||||
comment: ""
|
||||
)
|
||||
userNotification.soundName = NSUserNotificationDefaultSoundName
|
||||
NSUserNotificationCenter.default.deliver(userNotification)
|
||||
}
|
||||
}
|
||||
|
||||
// 一旦發現與使用者半衰模組的觀察行為有關的崩潰標記被開啟,就清空既有的半衰記憶資料檔案。
|
||||
if PrefMgr.shared.failureFlagForUOMObservation {
|
||||
LMMgr.clearUserOverrideModelData(.imeModeCHS)
|
||||
LMMgr.clearUserOverrideModelData(.imeModeCHT)
|
||||
PrefMgr.shared.failureFlagForUOMObservation = false
|
||||
let userNotification = NSUserNotification()
|
||||
userNotification.title = NSLocalizedString("vChewing", comment: "")
|
||||
userNotification.informativeText = NSLocalizedString(
|
||||
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.",
|
||||
comment: ""
|
||||
)
|
||||
userNotification.soundName = NSUserNotificationDefaultSoundName
|
||||
NSUserNotificationCenter.default.deliver(userNotification)
|
||||
DispatchQueue.main.async {
|
||||
LMMgr.clearUserOverrideModelData(.imeModeCHS)
|
||||
LMMgr.clearUserOverrideModelData(.imeModeCHT)
|
||||
PrefMgr.shared.failureFlagForUOMObservation = false
|
||||
let userNotification = NSUserNotification()
|
||||
userNotification.title = NSLocalizedString("vChewing", comment: "")
|
||||
userNotification.informativeText = NSLocalizedString(
|
||||
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.",
|
||||
comment: ""
|
||||
)
|
||||
userNotification.soundName = NSUserNotificationDefaultSoundName
|
||||
NSUserNotificationCenter.default.deliver(userNotification)
|
||||
}
|
||||
}
|
||||
|
||||
if !PrefMgr.shared.onlyLoadFactoryLangModelsIfNeeded { LMMgr.loadDataModelsOnAppDelegate() }
|
||||
|
|
|
@ -52,7 +52,9 @@ extension InputHandler {
|
|||
let newEvent = event.reinitiate(modifierFlags: [], characters: newChar)
|
||||
{
|
||||
if #available(macOS 10.14, *) {
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = true
|
||||
imkCandidates.handleKeyboardEvent(newEvent)
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = false
|
||||
} else {
|
||||
imkCandidates.interpretKeyEvents([newEvent])
|
||||
}
|
||||
|
@ -119,7 +121,9 @@ extension InputHandler {
|
|||
return event.isShiftHold ? true : handleInput(event: event)
|
||||
} else {
|
||||
if #available(macOS 10.14, *) {
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = true
|
||||
imkC.handleKeyboardEvent(newEvent)
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = false
|
||||
} else {
|
||||
imkC.interpretKeyEvents([newEvent])
|
||||
}
|
||||
|
|
|
@ -130,7 +130,9 @@ public extension SessionCtl {
|
|||
if #available(macOS 10.14, *) {
|
||||
// Spotlight 視窗會擋住 IMK 選字窗,所以需要特殊處理。
|
||||
if let ctlCandidateCurrent = candidateUI as? CtlCandidateIMK {
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = true
|
||||
ctlCandidateCurrent.setWindowLevel(UInt64(CGShieldingWindowLevel() + 2))
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,11 @@ public class CtlCandidateIMK: IMKCandidates, CtlCandidateProtocol {
|
|||
|
||||
public var candidateFont = NSFont.systemFont(ofSize: 16) {
|
||||
didSet {
|
||||
if #available(macOS 10.14, *) { setFontSize(candidateFont.pointSize) }
|
||||
if #available(macOS 10.14, *) {
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = true
|
||||
setFontSize(candidateFont.pointSize)
|
||||
PrefMgr.shared.failureFlagForIMKCandidates = false
|
||||
}
|
||||
var attributes = attributes()
|
||||
// FB11300759: Set "NSAttributedString.Key.font" doesn't work.
|
||||
attributes?[NSAttributedString.Key.font] = candidateFont
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"vChewing" = "vChewing";
|
||||
"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments.";
|
||||
"Do you want to enable the popup composition buffer for this client?" = "Do you want to enable the popup composition buffer for this client?";
|
||||
"Some client apps may have different compatibility issues in IMKTextInput implementation." = "Some client apps may have different compatibility issues in IMKTextInput implementation.";
|
||||
"Yes" = "Yes";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"vChewing" = "vChewing";
|
||||
"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments.";
|
||||
"Do you want to enable the popup composition buffer for this client?" = "Do you want to enable the popup composition buffer for this client?";
|
||||
"Some client apps may have different compatibility issues in IMKTextInput implementation." = "Some client apps may have different compatibility issues in IMKTextInput implementation.";
|
||||
"Yes" = "Yes";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"vChewing" = "威注音入力アプリ";
|
||||
"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK 文字候補ウィンドウの利用できるようのために、システム内部の必要のある API の強引的アクセスが必要ですが、前回のその利用で威注音入力アプリが崩れました。故に今は IMK 文字候補ウィンドウを OFF にしました。IMK 文字候補ウィンドウはあくまで実験的な機能として提供していたため、業務用にはお勧めできません。";
|
||||
"Do you want to enable the popup composition buffer for this client?" = "この客体アプリに「吹き出し入力緩衝列ウィンドウ」を起用しますか?";
|
||||
"Some client apps may have different compatibility issues in IMKTextInput implementation." = "それぞれの客体アプリには、それぞれの IMKTextInput 不具合はあるかもしれません。";
|
||||
"Yes" = "うむ";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"vChewing" = "威注音输入法";
|
||||
"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK 选字窗在最近一次存取被强制曝露的必需 API 时令输入法崩溃,所以被自动停用。请勿在生产力场合使用该实验型功能。";
|
||||
"Do you want to enable the popup composition buffer for this client?" = "您要對該客體啟用浮動組字窗嗎?";
|
||||
"Some client apps may have different compatibility issues in IMKTextInput implementation." = "有些客體應用可能會有不同的 IMKTextInput 實作相容問題。";
|
||||
"Yes" = "是";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
"vChewing" = "威注音輸入法";
|
||||
"IMK Candidate Window has been automatically disabled due to its recent crash with force-exposed necessary internal APIs. As an experimental feature, we advise against using IMK Candidate Window in productive environments." = "IMK 選字窗在最近一次存取被強制曝露的必需 API 時令輸入法崩潰,所以被自動停用。請勿在生產力場合使用該實驗型功能。";
|
||||
"Do you want to enable the popup composition buffer for this client?" = "您要对该客体启用浮动组字窗吗?";
|
||||
"Some client apps may have different compatibility issues in IMKTextInput implementation." = "有些客体应用可能会有不同的 IMKTextInput 实作相容问题。";
|
||||
"Yes" = "是";
|
||||
|
|
Loading…
Reference in New Issue