Skip to content

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

Open
k-kostin wants to merge 2 commits into
omacom:mainfrom
k-kostin:codex/fix-hover-grab-lifetime
Open

k-kostin wants to merge 2 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: 4/5

[Medium impact] The change reaches drag-picture preparation across Folio's list, column, and grid views.

The PR appears safe to merge, with a non-blocking request to cover delegate destruction in the tests.

Findings

  1. P2 Delegate destruction goes untested ▶

Summary

This PR moves hover-generated drag pictures into a C++ helper that keeps pending captures alive when rows or tiles disappear.

  • File hovers keep their drag pictures alive while Qt prepares them.

One non-blocking test gap remains: deleting the helper while its window stays open is not covered.

Reviews (1) · Last reviewed commit: "Retain pending grabs through completion ..." · 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!

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.

1 participant