Skip to content

Replace deprecated Process.launch() with try run() in ScreenCaptureHelper#1

Merged
afollestad merged 1 commit intoblock:mainfrom
jackfreem:jf/FixDeprecatedProcessLaunch
Feb 25, 2026
Merged

Replace deprecated Process.launch() with try run() in ScreenCaptureHelper#1
afollestad merged 1 commit intoblock:mainfrom
jackfreem:jf/FixDeprecatedProcessLaunch

Conversation

@jackfreem
Copy link
Collaborator

@jackfreem jackfreem commented Feb 24, 2026

Summary

  • captureSelection() returned nil for both user cancellation and launch failure, causing the caller to print "Screen capture cancelled." even when screencapture failed to start
  • captureSelection() now throws when Shell.runCommand returns exitCode -1 (launch failure), so nil is reserved for genuine user cancellations
  • The caller wraps the call in do/catch: launch failures print "Screen capture failed:" and exit with a non-zero status

Test plan

  • Running qrgo --capture and selecting a screen region captures the image and decodes a QR code as expected
  • Cancelling the screen capture (Escape) prints "Screen capture cancelled." with no crash
  • Temporarily change launchPath to a nonexistent path, run qrgo --capture, verify it prints "Screen capture failed:" and exits non-zero (not "Screen capture cancelled.")

Copilot AI review requested due to automatic review settings February 24, 2026 22:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates ScreenCaptureHelper.captureSelection() to use Process.run() (with error handling) instead of the deprecated Process.launch() when invoking macOS screencapture, aligning with the file’s other Process call sites.

Changes:

  • Replaced deprecated task.launch() with try task.run() in captureSelection()
  • Added do/catch to handle launch failures and return nil on error

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

captureSelection() now throws when screencapture fails to launch
(Shell.runCommand returns exitCode -1), so the caller only reaches
"Screen capture cancelled." for genuine user cancellations. Launch
errors print "Screen capture failed:" and exit(1).
@jackfreem jackfreem force-pushed the jf/FixDeprecatedProcessLaunch branch from 63c3140 to 3b036f7 Compare February 25, 2026 17:16
@jackfreem jackfreem marked this pull request as ready for review February 25, 2026 17:18
@afollestad afollestad merged commit 49f5051 into block:main Feb 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants