fix(macos): fix clipboard copy failing from tray and GUI#4629
Open
Mitnitsky wants to merge 1 commit intoflameshot-org:masterfrom
Open
fix(macos): fix clipboard copy failing from tray and GUI#4629Mitnitsky wants to merge 1 commit intoflameshot-org:masterfrom
Mitnitsky wants to merge 1 commit intoflameshot-org:masterfrom
Conversation
Collaborator
|
This worked well and can be merged after addressing clang-format. The bug was introduced here. I am not sure why I didn't catch it in original testing: #4473 |
The clipboard copy from tray menu and capture GUI was broken on macOS:
1. FlameshotDaemon::copyToClipboard() created a KDSingleApplication
instance and called isPrimaryInstance(), which always returned false
(the daemon already holds the socket). This caused a 3-second IPC
timeout before falling back. Fix: use instance() to check if the
daemon singleton exists in-process, matching non-macOS behavior.
2. saveToClipboardMime() used setData("image/...") which puts a lazy
reference on the macOS pasteboard. If the app exits before paste,
data is lost ("Cannot keep promise"). Fix: use setImageData() for
native pasteboard persistence, plus setData() for exact format.
3. saveJpegToClipboardMacOS() used osascript with a temp file and
incorrectly labeled JPEG data as PNG UTI. Removed entirely — the
fixed saveToClipboardMime() now handles both JPEG and PNG.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
04ff785 to
f6c61b1
Compare
Contributor
Author
|
Addressed the clang-format, should pass now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Copying screenshots to clipboard on macOS was broken in two ways:
3-second delay + clipboard empty:
copyToClipboard()created aKDSingleApplicationinstance and calledisPrimaryInstance(), whichalways returned
falsebecause the daemon already holds the socket.This triggered IPC message delivery instead of using the in-process
daemon directly. The IPC timed out after ~3 seconds and clipboard was
never set.
Lazy clipboard data lost on exit:
setData("image/png")puts alazy reference on the macOS pasteboard — if the process exits before
paste, data is lost ("Cannot keep promise"). The separate
saveJpegToClipboardMacOS()workaround used osascript with a tempfile and incorrectly declared JPEG data as PNG UTI (
«class PNGf»).Fix
isPrimaryInstance()check on macOS — useinstance()tocheck if the daemon singleton exists in-process, matching non-macOS
behavior. IPC fallback is preserved for true secondary processes (CLI).
saveToClipboardMime()usingsetImageData(QImage)for native pasteboard persistence (
public.tiff) plussetData()forexact format availability (PNG or JPEG).
saveJpegToClipboardMacOS()entirely — the fixedsaveToClipboardMime()now handles both formats correctly.All changes are guarded with
#if defined(Q_OS_MACOS). The Linux, Windows,and Wayland clipboard paths are unchanged.
Testing
Tested on macOS 26.4 (Tahoe), Apple Silicon, Qt 6.11.0:
flameshot full --clipboard: works via IPC fallbackcloses #4630