Commit fda6040
Fixes NullReferenceException in AdornmentView.Contains when Adornment is null (#4884)
AdornmentView has a parameter-less constructor (for AllViewsTester reflection
support) that leaves Adornment = null. When such a view is placed inside a
SuperView (e.g. the Themes UICatalog scenario creates AdornmentView/MarginView
via reflection), moving the mouse over it caused a NullReferenceException at
Adornment!.Thickness.Contains(...) because the null-forgiving ! operator did
not prevent the dereference.
Fix: add a guard clause returning false when Adornment is null, matching the
existing pattern used in OnClearingViewport, OnDrawingText, and
OnDrawingSubViews.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Tig <tig@users.noreply.github.com>1 parent 9d40ced commit fda6040
2 files changed
Lines changed: 31 additions & 1 deletion
File tree
- Terminal.Gui/ViewBase/Adornment
- Tests/UnitTestsParallelizable/ViewBase/Adornment
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
196 | | - | |
| 201 | + | |
197 | 202 | | |
198 | 203 | | |
199 | 204 | | |
| |||
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
0 commit comments