Skip to content

gui: reclaim layout callback lifetimes#62

Open
GGRei wants to merge 1 commit into
vlang:mainfrom
GGRei:fix/gui58-closure-lifetime-reclaim
Open

gui: reclaim layout callback lifetimes#62
GGRei wants to merge 1 commit into
vlang:mainfrom
GGRei:fix/gui58-closure-lifetime-reclaim

Conversation

@GGRei

@GGRei GGRei commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

This uses the closure lifetime/reclaim API to reclaim transient layout callbacks in v-gui.

Window.update() now builds each layout tree inside a layout callback lifetime frame, keeps the current layout alive, and reclaims old frame-owned closure contexts after the new layout has been installed.

Persistent callbacks created during layout, such as animations, hover-created callbacks, async data sources, CRUD saves, and deferred drag/drop callbacks, are kept alive outside the transient reclaim scope when needed.v

Codex review validation is available here: GGRei#2

Fix #58

Changes

  • Add a small v-gui wrapper around the V closure lifetime API.
  • Track layout callback closures during Window.update().
  • Reclaim old layout-owned callbacks after replacing the layout tree.
  • Dispose layout callback lifetime state during window cleanup.
  • Keep persistent animations and hover-created callbacks outside frame reclaim.
  • Pin async data-grid and listbox source callbacks until completion/abort.
  • Pin async data-grid CRUD save callbacks until queued completion is applied.
  • Snapshot drag-reorder layout transitions before user drop handlers can rebuild layout.
  • Add regression coverage for layout callback memory growth, current-layout callback survival, persistent callbacks, async source callbacks, CRUD callbacks, drag reorder ordering, mouse lock callbacks, and idempotent cleanup.

Dependency

This PR depends on vlang/v#27483.

⚠️ Until vlang master includes vlang/v#27483, CI failures are expected because this PR uses the new closure lifetime/reclaim API. Please rerun the checks once the compiler PR is merged.

Tests

/home/alex-portable/external_work/vlang_closure_lifetime_api_20260617/./v -o v_gui_verify cmd/v

/home/alex-portable/external_work/vlang_closure_lifetime_api_20260617/v_gui_verify test _window_lifetime_test.v
/home/alex-portable/external_work/vlang_closure_lifetime_api_20260617/v_gui_verify test _drag_reorder_test.v

git diff --check

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.

Memory leak

1 participant