Fix angular ticks nre 2012 - #2079
Conversation
|
Thanks for your contribution! The build and test process is starting. This may take a while. All packages have been packed successfully! 📦✅ The packages will be available for 30 days, you can either use them directly, or wait for this PR to be merged to have them published to NuGet.org. Tests will start now, you can monitor their progress below or at the actions tab. Test Results Summary (Passed) ✅ 🥳0 skipped. |
There was a problem hiding this comment.
Pull request overview
This PR fixes a NullReferenceException that occurs when the MaxValue of a PieChart with angular ticks changes dynamically. The issue occurred because the Subseparator array in angular ticks is intentionally sparse - it's created with size 5 but only indices 0-3 are initialized, leaving index 4 as null. When the chart scale changes and old tick visuals are removed, the cleanup code attempted to remove all subseparators including the null ones, causing the crash.
Changes:
- Added a null check before calling RemoveGeometryFromPaintTask on subseparators in the cleanup loop
- Added a regression test that reproduces the issue by creating a PieChart with angular ticks and changing its MaxValue
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/LiveChartsCore/VisualElements/BaseAngularTicksVisual.cs | Added null check in cleanup loop to handle intentionally null subseparator array elements |
| tests/CoreTests/ChartTests/ChartTests.cs | Added regression test that changes MaxValue on a PieChart with angular ticks to verify the fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fixes #2012