Skip to content

Fix: clear the display mark on a view with no area - #867

Open
DTW-Thalion wants to merge 2 commits into
gnustep:masterfrom
DTW-Thalion:fix/empty-view-needs-display
Open

Fix: clear the display mark on a view with no area#867
DTW-Thalion wants to merge 2 commits into
gnustep:masterfrom
DTW-Thalion:fix/empty-view-needs-display

Conversation

@DTW-Thalion

@DTW-Thalion DTW-Thalion commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Both of NSView's display walks reach a subview only when the rectangle being displayed and the subview's frame overlap. A subview with no width or height never overlaps anything, so it is never displayed, its mark is never cleared, and both walks copy that mark up to every view above it. An NSBox two pixels high is enough: it leaves its content view a height of zero, and from then on that view, the box, the window's content view and the frame view all answer YES to -needsDisplay for good.

When the overlap is empty because the subview has no area, it is now asked to display an empty rectangle, which clears its mark. A subview that has an area and merely falls outside the rectangle keeps its mark, and there is an assertion for that.

This turned up in the alert panel of #80, whose separator is such a box. The symptom reported there, contents invisible until the panel is moved, does not reproduce on Windows against current master, whether the alert is raised before the application loop starts or from inside a running one. This mark is the only defect found on that path.

Tests/gui/NSView/emptyViewNeedsDisplay.m: 5 of its 7 assertions fail before the change and none after. Tests/gui runs 4345 assertions green.

Closes #80

Both display walks reach a subview only when the rectangle being
displayed and the subview's frame overlap. A subview whose frame has no
width or height never overlaps anything, so it is never displayed, its
mark is never cleared, and both walks copy that mark up to every view
above it. An NSBox two pixels high is enough: its content view is left
with a height of zero, and from then on the content view and the frame
view of that window answer YES to -needsDisplay for good.

When the overlap is empty because the subview itself has no area, let
the subview run the display for an empty rectangle, which clears its own
mark. A subview that has an area and merely falls outside the rectangle
keeps its mark, as it should.
@rfm

rfm commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Cool thing to spot.

@fredkiefer

Copy link
Copy Markdown
Member

Looks great, but I will have to review the whole working here. I wrote most of that, but that was a long time ago and I have to understand all of it again. Sorry,we could also just merge and I go through that later on.

START_SET creates an autorelease pool and END_SET releases it, so the pool
these tests create around the set is redundant.
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.

Contents of NSAlert not visible until window is moved on WINDOWS

3 participants