Added null srcImage check to the other DrawTexture overload.#2785
Merged
KABoissonneault merged 2 commits intoApr 12, 2026
Conversation
|
|
||
| void DrawTexture(ImageData srcImage, DaggerfallUnityItem item = null) | ||
| { | ||
| if (srcImage.texture == null) |
Collaborator
There was a problem hiding this comment.
Question, why does this not check srcImage and srcImage.offset for null instead?
Contributor
Author
There was a problem hiding this comment.
- srcImage can be not null since GetCloakInteriorImage() returns a new uninitialized ImageData if the item is not a cloak
- I wanted to keep it consistent with Null check ImageData for BlitCloakInterior #2757
- I suppose that there's no use-case for calling DrawTexture() if the srcImage has no texture so it's better to abort it here than later?
Collaborator
There was a problem hiding this comment.
Fair enough about the first point, but the second point is irrelevant. The convention that matters here is checking for null before access. The third point is fine, you can check the texture for null even if it's not directly accessed, but for safety I'd wanna make sure any field that can be null is checked before access.
In short, you can have if(srcImage.texture == null || srcImage.offset == null)
Contributor
Author
There was a problem hiding this comment.
Understood. I'll revise it as directed.
KABoissonneault
approved these changes
Apr 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends #2757 to prevent the exception in #2740 from happening by calling the overload.