Skip to content

fix: null ref in view hierarchy #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 25, 2024
Merged

Conversation

bruno-garcia
Copy link
Member

@bruno-garcia bruno-garcia commented Nov 23, 2024

Resolves: #1918

Skips possible null components before trying to get their type info.

Not sure how to test this because it depends on a Unity API GetComponents

Also: replaced the LINQ call with a foreach and allocated a new List with the known size to avoid resizes.

var extras = new List<string>(components.Count);
foreach (var component in components)
{
if (component?.GetType().Name is { } componentName)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stack trace on #1918 led me to believe GetComponents is adding null to entries to the List it receives as argument.

@bruno-garcia
Copy link
Member Author

CI is showing green here but only 5 checks show. I had to cancel CI due to #1920

Copy link
Contributor

@bitsandfoxes bitsandfoxes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 🚒

@bitsandfoxes
Copy link
Contributor

CI is showing green here but only 5 checks show.

CI will skip if the only changes are made to .txt or .md - i.e. the changelog.

on:
push:
paths-ignore:
- "**.md"
- "**.txt"
workflow_dispatch: # e.g. to manually trigger on foreign PRs

@bitsandfoxes bitsandfoxes merged commit 23ddd15 into main Nov 25, 2024
5 checks passed
@bitsandfoxes bitsandfoxes deleted the fix/null-component-viewhierarchy branch November 25, 2024 11:22
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.

NullReferenceException with ViewHierarchy
2 participants