Lock for writing in ControlCore::SetBackgroundOpacity (#10357)

## PR Checklist
* [x] Closes random crash that @lhecker sent me on Teams
* [x] I work here.

## Detailed Description of the Pull Request / Additional comments
- Any change to the renderer engine has to be done under lock. Leonard gave me a crash where the dirty rectangles changed out from under the renderer thread. By inspection, only one spot in `ControlCore` is modifying the engine outside of lock.... here. The dump is too far along to definitively prove the issue and it's sort of a race so its difficult to repro. But the theory is sound that all writes to the dirty regions must be done under lock. So here's a fix.

(cherry picked from commit 94d39b7580)
This commit is contained in:
Michael Niksa 2021-06-09 09:55:41 -07:00 committed by Dustin Howett
parent dbe688dcd9
commit d49d045bd9
No known key found for this signature in database
GPG key ID: 0719BB71B334EE77

View file

@ -1126,6 +1126,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
if (_renderEngine)
{
auto lock = _terminal->LockForWriting();
_renderEngine->SetDefaultTextBackgroundOpacity(::base::saturated_cast<float>(opacity));
}
}