-
-
Notifications
You must be signed in to change notification settings - Fork 22.2k
Add null check for SpriteFramesEditor's SpriteFrames #104830
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
Conversation
Pretty sure there doesn't need to be a null check in every method 🤔 Some of the checks can't be probably reached. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes the crash, but looks like overkill to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say we should at least consider the error being elsewhere first, or at least reduce the number of cases here, it feels very brute force to solve the problem this way
IMO, we should:
- Establish that this is the place to fix this, and make sure there methods being called with
frames.is_null() == true
is correct - Establish which cases specifically need to be solved this way
This at the surface looks like solving the problem in the wrong place, at least without a deeper evaluation
In my experience adding null-checks, especially for states belonging to the object itself, is solving a symptom not a cause
698f5de
to
d762ee3
Compare
Got it. I've removed unnecessary null checks.
While I can understand where you're coming from, IMO this is consistent with how AnimationTrackEditor handles the same issue. For example, here. (A lot of similar examples can be found in the same file) The other solution I had in mind was to disconnect the signals causing the crashes when |
This sounds fine, my main concern was with if the check should just be elsewhere If this is caused by signals or other things like that I think it's fine to do things this way! It's more a question of "is this the best way to solve this", if the other way would be convoluted messing with signals then this is fine |
This particular crash is caused by the SpriteFrames editor getting hidden, which causes We could keep the fix limited to this single case. That risks another crash being discovered elsewhere, but prevents having too many unnecessary checks. |
d762ee3
to
19e8faa
Compare
That's fine too. Though I'll keep the null check in |
Thanks! |
Fixes #104822
Adding missing null checks for
frames
seems to be more in-line with existing code, (see also: AnimationTrackEditor'sanimation.ptr()
null checks) so this is the solution I ended up with.