[3.x] Fix a crash when trying to load a WebP StreamTexture
#51014
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.
Fixes #51003.
Though I am not sure exactly what is going on here. For some reason with the existence of a theme specifically a
StreamTexture
is attempting to get loaded when it reasonably cannot because, I think,ImageLoaderWEBP
hasn't been initialized yet (hence the crash,Image::webp_unpacker
points nowhere). I found other places checking for validity of*_unpacker
methods, so I added same checks here.It doesn't crash anymore, and still loads fine, but that only tells me there are some other problems which are hidden. First of all, it's weird to attempt to load a texture so early with a theme. Adding the same texture to a scene doesn't cause that (or I didn't test it properly). Second of all, the checks that I've added should prevent the texture from loading (as we cannot do that at that moment) yet it still loads in the end and there are no visible glitches for the user. So there is probably some redundancy somewhere that attempts to load it again later? Maybe it's not that bad, but it's still troubling.
Either way, the crash is fixed (from my testing) and the texture is loaded fine.