Repository navigation
Fix first text edit being discarded after double-click - #5059
Open
ZainnQureshii wants to merge 1 commit into
Open
ZainnQureshii wants to merge 1 commit into
ZainnQureshii wants to merge 1 commit into
Conversation
Double-clicking a text annotation took the edit pointer and turned on edit mode before refreshing the layers panel. The refresh rebuilds the layer list, which emits layerChanged; updateActiveLayer then pushes the pending size change to the undo stack, and the redo replaces the stored objects with copies. The editor was left pointing at the old object, so the first edit was dropped when the user clicked outside. Refresh the layers panel first and fetch the text tool again afterwards, so the editor and its undo snapshot use the stored annotation. Fixes flameshot-org#4062 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mmahmoudian
approved these changes
Nov 17, 2026
Member
|
Thanks for the PR and clarification about AI. It worked smoothly and code change makes sense to me. I'd wait for @borgmanJeremy review/merge. |
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.
Fixes #4062
What was wrong
Following the steps in #4062 (type text, switch to a tool with a different size, double-click the text, edit it, click outside), the first edit is thrown away and the text goes back to its old content. A second edit works.
CaptureWidget::mouseDoubleClickEventtook the text tool pointer and turned on edit mode, and only then calledupdateLayersPanel(). That refresh rebuilds the layer list (UtilityPanel::fillCaptureTools), which emitslayerChanged.CaptureWidget::updateActiveLayerthen seesm_existingObjectIsChanged(set byonToolSizeChangedwhen selecting the text moves the size away from the previous tool's) and callspushObjectsStateToUndoStack(). The pushedModificationCommand::redoreplaces the stored objects throughsetCaptureToolObjects, which deep-copies them. The editor was left attached to the old object, so the edit never reached the stored annotation.This matches what borgmanJeremy found in the issue: the bug needs the second tool to have a different size, and it goes away if that size line is commented out.
The change
In
mouseDoubleClickEvent, callupdateLayersPanel()before setting up the edit, and fetch the text tool again fromm_captureToolObjectsafter the refresh. Any pending size change is committed first, and the editor and its undo snapshot use the stored annotation. One call moved earlier and the text tool is fetched again after it; nothing else changed, and the size and color handlers are as on master.How it was tested
Built master and this branch with CMake + Ninja (Qt 6, macOS, Debug); both build. CTest registers no tests in this repo, so I used an offscreen harness (
QT_QPA_PLATFORM=offscreen) that links the app's own objects, creates real text and rectangle tools, and drives them through mouse events and the side panel's real hex color editor and size slider:Not covered here, and failing the same way on master and this branch: Escape closing the editor before undo, resizing while the editor is open, and an unchanged edit adding an undo entry. I did not run it in a visible GUI session.
The changed lines are unchanged by clang-format (checked with a current clang-format on the changed lines; CI's pinned clang-format 11 has no arm64 macOS build).
Prepared with AI assistance (Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code