Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix racy access to _tsfTryRedrawCanvas in TermControl (#10549)
Previously `TermControl::Close` destroyed all `ThrottledFunc`s to ensure they're not scheduling any callbacks on the UI thread, as the call to `Close` signals the point at which the `TermControl` isn't part of the UI thread anymore. `_CursorPositionChanged` tried to prevent access to the potentially deallocated `_tsfTryRedrawCanvas` by checking the `std::shared_ptr` for nullability, but since the deallocation happens on the UI thread and the nullability check on a background thread, this check introduced a race condition. This commit solves the issue by not deallocating any `ThrottledFunc`s anymore and instead checking the `_closing` flag inside the `ThrottledFunc` callback on the UI thread. Additionally this commit cleans up some antipatterns around the use of `std::optional`. ## PR Checklist * [x] Closes #10479 * [x] Closes #10302 ## Validation Steps Performed * Opening and closing tabs doesn't crash ✔️ * Printing long text doesn't crash ✔️ * Manual scrolling doesn't crash ✔️ * ^G / the audible bell doesn't crash ✔️
- Loading branch information