Prevent crash when processing line caches in RichTextLabel
#78975
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 #78912.
Fixes #78849.
Fixes #78932.
Supersedes #78916 as a solution (though sizing changes may be welcome at some point).
I investigated #78241 which introduced this regression and noticed a small logical difference in what appeared to be a simple act of refactoring. We used the old value of
scroll_w
, valid only at the time of the function call, while in the process the value ofscroll_w
was updated. This broke pre-existing logic from before the refactoring resulting in the crash.I admit, I don't really understand the entirety of what's going on, but this doesn't seem intentional and does seem to be the source of the issue.
PS. There is also another difference in that refactoring which I haven't touched because it has nothing to do with the crash. But when we do
_process_line_caches
we used to callmain->first_invalid_line.store
andmain->first_invalid_font_line.store
while iterating. In the factored out code of_update_scroll_exceeds
this no longer happens, and onlymain->first_resized_line.store
is called. Might be something to look into.