Skip to content

Keep drag-picture grabs alive when delegates disappear - #196

Merged
dhh merged 3 commits into
omacom:mainfrom
k-kostin:codex/fix-hover-grab-lifetime
Nov 21, 2026
Merged

dhh merged 3 commits into
omacom:mainfrom
k-kostin:codex/fix-hover-grab-lifetime

Conversation

@k-kostin

Copy link
Copy Markdown
Contributor

Summary

Rapid PageDown/PageUp scrolling with the pointer over a row can crash Folio while Qt is preparing its drag picture. Reproduced on unmodified main at 905999e, without #122 applied.

hover -> Qt grabToImage (C++ shared-pointer overload)
      -> retain pending grab through completion or window teardown
      -> update the current delegate's drag picture

A small public-Qt helper preserves the existing hover-generated pictures in lists, columns and the grid. Superseded requests can finish safely; discarded delegates receive no reply. No new dependencies.

Related to #122 because both touch the row's drag-picture handling. This PR is based directly on main and can be reviewed independently. If #122 lands first, I'll adapt this fix to it and rerun the relevant checks.

Evidence

  • Before: Six fresh main processes ran the same native PageDown/PageUp workload: four crashed with SIGSEGV; two completed the input but timed out on close. The close hangs were not separately diagnosed. A control with an empty grab callback also crashed inside QQuickItemGrabResult::render().
    After: Six fresh processes completed all 2,160 keypresses and closed normally; an additional process completed 1,080 keypresses and closed normally.
  • Tested on Qt 6.12 / NVIDIA 615.78.08 / Hyprland 0.56.2. These are bounded reproduction results on the affected machine.
  • bin/test -V: 253 passed, 0 failed, 1 environmental skip (root-drive trash requires writable / without .Trash).
  • Image/replacement/destruction tests passed at scales 1 and 2 and on native Wayland. Native drag/drop and Escape passed for both row and tile delegates.
  • The small Qt-only probe did not reproduce the race. The whole-app native replay provides the before/after evidence; software-renderer tests cover image and ownership behavior.

Merge Danger

Door: Two-way — code-only change, no data migration.

Blast Radius: Drag pictures — shared by list, column and grid delegates.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge.

Summary

The PR keeps pending drag pictures alive when rows or tiles disappear. The latest update adds the missing test for removing an item while its window stays open.

  • File rows and tiles keep drag pictures alive while grabs finish.

Reviews (2) · Last reviewed commit: "Test pending grabs when a delegate disap..." · Reviewed by Greptile

Comment thread tests/folio_tests.cpp
Comment on lines +641 to +648
QVERIFY(picture->capture(source));
if (i % 2 == 0) {
delete source;
// A rendered frame is the boundary for the pending grab.
QSignalSpy frame(window, &QQuickWindow::frameSwapped);
window->update();
QTRY_VERIFY(!frame.isEmpty());
QCOMPARE(ready.count(), 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Delegate destruction goes untested. The source-deletion branch leaves picture alive, so its m_grab still holds the pending capture. The other branch deletes the whole window. Neither covers scrolling a delegate away, where both the source and DragPicture disappear while the window keeps rendering—the case that needs the new window-held reference.

Add a branch that deletes both objects after capture(), leaves the window open, and waits for another frame. This would cover the ownership path this fix adds.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, added the missing case. The test now starts a grab, destroys the delegate containing both the source and DragPicture, and waits for another frame with the window still open. It checks that both objects were destroyed and no ready signal was delivered. The source-only and window-close cases remain covered.

Passed at scales 1 and 2 and on native Wayland. The full suite passed: 253 passed, 0 failed, 1 environmental skip.

@dhh
dhh merged commit 69606a4 into omacom:main Nov 21, 2026
2 checks passed
dhh added a commit to k-kostin/folio that referenced this pull request Nov 21, 2026
The list made a new row for every file scrolled in and threw away every
row scrolled out. Turning on reuseItems gives the rows scrolled out to
the files scrolled in instead; scrolling 3,000 files through the list
offscreen took 1.5 s of layout before and 0.16 s after.

Nearly everything a row shows is bound to its file's roles, so follows
the file it's given. What isn't is the picture taken for dragging it:
a row given another file under a still pointer stays hovered, so takes
no new one, and a drag from there showed the file before. A reused row
now drops that picture and, still hovered, takes a new one.

The rest of the pilot's guards are dropped: the pooled state gating
every handler, the Loader around the tap handler, the arrow's pressed
path, the drag generations and holding reuse off during a drag. They
cover a mouse button held through a page of scrolling, a double-click
split by a jump that moves the cursor, or a scroll during a drag the
system holds; and the drag picture's superseded grabs are already
ignored by DragPicture since omacom#196. The tests go down to one for the
picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dhh added a commit that referenced this pull request Nov 21, 2026
* Pilot tree-list row reuse for rendered-frame measurements

* Cancel a tree arrow press when its row is pooled

* Cover reused tree rows, thumbnails and pointer lifecycles in the main test suite

* Check thumbnail pixels at display scale and assert reused tree arrows

* Keep only the reset a reused row needs

The list made a new row for every file scrolled in and threw away every
row scrolled out. Turning on reuseItems gives the rows scrolled out to
the files scrolled in instead; scrolling 3,000 files through the list
offscreen took 1.5 s of layout before and 0.16 s after.

Nearly everything a row shows is bound to its file's roles, so follows
the file it's given. What isn't is the picture taken for dragging it:
a row given another file under a still pointer stays hovered, so takes
no new one, and a drag from there showed the file before. A reused row
now drops that picture and, still hovered, takes a new one.

The rest of the pilot's guards are dropped: the pooled state gating
every handler, the Loader around the tap handler, the arrow's pressed
path, the drag generations and holding reuse off during a drag. They
cover a mouse button held through a page of scrolling, a double-click
split by a jump that moves the cursor, or a scroll during a drag the
system holds; and the drag picture's superseded grabs are already
ignored by DragPicture since #196. The tests go down to one for the
picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Kirill Kostin <15322854+k-kostin@users.noreply.github.com>
Co-authored-by: David Heinemeier Hansson <david@hey.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants