Skip to content

Fix: keep NSStackView arranged subviews in the subview list - #825

Merged
fredkiefer merged 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/nsstackview-arranged-membership
Jul 27, 2026
Merged

fredkiefer merged 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/nsstackview-arranged-membership

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

-addArrangedSubview: only appended to the internal arranged list and never made the view a subview, while -arrangedSubviews returned -subviews, so an added view was reported by neither and the count came out wrong. -insertArrangedSubview:atIndex: also skipped the refresh, and -setArrangedSubviews: retained the passed array directly, so a later -addArrangedSubview: could mutate a possibly immutable array.

-arrangedSubviews now returns the arranged list, and the mutators keep it and the subviews in step to match AppKit (checked on a macOS runner):

  • addArrangedSubview:/insertArrangedSubview:atIndex: make the view a subview and deduplicate it; insert orders the arranged list while the subview stays appended
  • removeArrangedSubview: drops it from the arranged list but leaves it as a subview
  • removeFromSuperview drops it from both, through -willRemoveSubview:
  • a plain -addSubview: is a subview but not arranged

New Tests/gui/NSStackView/membership.m covers this.

This is the arranged-subview half of #628. The layout half (the custom -_layoutViewsWithOrientation: pass that grows the frame instead of building constraints) needs the constraint solver in #643, so the geometry the arranged views get is unchanged here and the issue stays open for that part.

-addArrangedSubview: only appended to the internal arranged list and
never made the view a subview, while -arrangedSubviews returned
-subviews, so an added view was reported by neither and the count came
out wrong. -insertArrangedSubview:atIndex: also skipped the refresh, and
-setArrangedSubviews: retained the passed array directly, so a later
-addArrangedSubview: mutated a possibly immutable array.

-arrangedSubviews now returns the arranged list, and the mutators keep it
and the subviews in step to match AppKit: adding or inserting makes the
view a subview and deduplicates it, removeArrangedSubview: drops it from
the arranged list but leaves it as a subview, and removeFromSuperview
drops it from both through -willRemoveSubview:. A plain -addSubview: is a
subview but not arranged.

The constraint-based layout is a separate change, so the geometry the
arranged views get is unchanged here.
@DTW-Thalion
DTW-Thalion requested a review from fredkiefer as a code owner July 27, 2026 13:59
@fredkiefer
fredkiefer merged commit 9615508 into gnustep:master Jul 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants