From 833266150473b3fd1b4f118dfba101fcbc42708c Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 9 Sep 2026 12:29:53 +0800 Subject: [PATCH] Guard against event-tap teardown crashes; log result-window display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A tap-disabled callback force-unwrapped the tap port, which could crash the app mid-capture (no result window, dead hotkey). Guard it and log re-enables. Result window display is now logged with the image size. 💘 Generated with Crush Assisted-by: Crush:deepseek-v4-flash-0731 --- Sources/Kapture/CaptureController.swift | 12 +++++++----- build-app.sh | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Sources/Kapture/CaptureController.swift b/Sources/Kapture/CaptureController.swift index 1598071..f7f5534 100644 --- a/Sources/Kapture/CaptureController.swift +++ b/Sources/Kapture/CaptureController.swift @@ -265,11 +265,12 @@ final class CaptureController: NSObject { guard isSelecting else { return event } switch type { - case .tapDisabledByUserInput: - CGEvent.tapEnable(tap: eventTap!, enable: true) - return event - case .tapDisabledByTimeout: - CGEvent.tapEnable(tap: eventTap!, enable: true) + case .tapDisabledByUserInput, .tapDisabledByTimeout: + // A timed-out tap must be re-enabled; guard against a torn-down tap. + if let tap = eventTap { + CGEvent.tapEnable(tap: tap, enable: true) + CaptureController.log("tap: re-enabled after \(type)") + } return event case .keyDown: if event.getIntegerValueField(.keyboardEventKeycode) == 53 { @@ -342,6 +343,7 @@ final class CaptureController: NSObject { ResultWindow.shared.show(image: ResultWindow.failureImage("Capture failed. Check Screen Recording permission.")) return } + CaptureController.log("capture done: \(image.width)x\(image.height) — showing result window") ResultWindow.shared.show(image: image) } } diff --git a/build-app.sh b/build-app.sh index 50ce6f4..a8cd724 100755 --- a/build-app.sh +++ b/build-app.sh @@ -108,9 +108,9 @@ cat > "$APP/Contents/Info.plist" <<'PLIST' CFBundleIconFile Icon CFBundleShortVersionString - 1.7.2 + 1.7.3 CFBundleVersion - 72 + 73 LSUIElement NSHighResolutionCapable