Skip to content

fix(signals): address review follow-ups on helpers, weak slots, and macOS mirrors - #4

Merged
makoni merged 2 commits into
mainfrom
fix/signal-review-polish
Oct 9, 2026
Merged

makoni merged 2 commits into
mainfrom
fix/signal-review-polish

Conversation

@makoni

@makoni makoni commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Review follow-ups on the value-returning signal series (49a476d, b8dee0c):

  • spinRowEditableText moved out of Sources/Adwaita/Generated/SpinRow.swift into Sources/Adwaita/SpinRow+Editable.swift (internal), so a regenerated Generated/SpinRow.swift compiles — the generator emits the call but never the definition. Verified by building the codegen from Tools/AdwaitaCodeGen, running it from an empty dir, and diffing the onInput/onOutput/onGetNextPage/onClosePage/onCreateWindow/onCreateTab bodies against the repo files (identical; doc-comment/manual divergences left untouched per the workflow).
  • New test tabViewOnClosePageReturnFalseClosesPage: handler returns false and does not call closePageFinish → the default close must happen (nPages == 0).
  • drag-cancel trampoline: signalTrampolineDragCancel and the connectDragCancel cast now take OpaquePointer? instead of OpaquePointer — the emit shim and the test pass NULL, which was formally UB.
  • New regression test spinRowOnInputSignalDoesNotLeakRow: creates a SpinRow, connects onInput, drops the wrapper, spins the main loop, and asserts the C object finalized via a weak pointer. Verified it fails when the old self capture is temporarily restored, then reverted.
  • Stable weak-pointer slots: weak-pointer tests now pass a heap slot (WeakPointerSlot test helper: allocate/initialize/deallocate) to g_object_add_weak_pointer instead of &local, whose address Swift only guarantees for the duration of the call.
  • macOS mirrors: added the missing one-to-one XCTest mirrors (InputDialog: drag-cancel; MediaProtocol: spinRow onOutput/onInput ×3; NavigationAndTab: close-page ×4, create-window ×2, get-next-page) and renamed test_tabOverviewCreateTabSignal → test_tabOverviewCreateTabSignalConnect. Main-loop tests (navigationViewOnGetNextPageFinalizesOnce, tabOverviewCreateTabSignalAddsAndFinalizesPage, the new leak test) stay swift-testing-only per CONTRIBUTING.md.

Checks (local):

  • swift build && swift build --build-tests — clean
  • xvfb-run -a swift test --no-parallel — 1322 + 10 passed (was 1320 + 10)
  • CRITICAL/WARNING log diff vs main: identical (only PIDs/timestamps)
  • swiftformat 0.60.1 --lint Sources/ Tests/ — 0 violations

makoni added 2 commits October 9, 2026 18:11
…acOS mirrors

- move spinRowEditableText out of Generated/SpinRow.swift into
  Sources/Adwaita/SpinRow+Editable.swift (internal) so regenerated
  Generated/SpinRow.swift still compiles; the generator already emits
  the call but never the definition
- make signalTrampolineDragCancel / connectDragCancel take
  OpaquePointer? instead of OpaquePointer (the emit shim and the
  test pass NULL; a non-optional parameter is formally UB)
- add tabViewOnClosePageReturnFalseClosesPage: a false return must
  fall through to the default close (nPages == 0)
- add spinRowOnInputSignalDoesNotLeakRow: regression test for the
  old self-capture leak (verified to fail when the capture is
  temporarily restored)
- route g_object_add_weak_pointer through a stable heap slot
  (WeakPointerSlot) instead of &local, which Swift only guarantees
  for the duration of the call
- add the missing one-to-one XCTest mirrors for the new signal
  tests and rename test_tabOverviewCreateTabSignal to
  test_tabOverviewCreateTabSignalConnect
WeakPointerSlot.deinit now drops the g_object_add_weak_pointer
registration when the watched object is still alive, so GLib can no
longer write into a freed slot during a later finalization (e.g. when
a test fails early and the object outlives the slot). Drop the
unused GObjectSupport import from SpinRow+Editable.swift.
@makoni
makoni merged commit 5b10512 into main Oct 9, 2026
5 checks passed
@makoni
makoni deleted the fix/signal-review-polish branch October 9, 2026 11:51
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