Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework TermControl's initialization (#5051)
This commit rewrites a large swath of TermControl's initialization code. * `TermControl` now _always_ has a `_terminal`; it will never be null * Event registration for `_terminal` and any other available-at-init fixtures has been moved into the constructor. * Event handlers how more uniformly check `_closing` if they interact with the _terminal. * Swap chain attachment has been cleaned up and no longer uses a coroutine when it's spawned from the UI thread. * We have to register the renderer's swapchain change notification handler after we set the swap chain, otherwise it'll call us back when it initializes itself. * `InitializeTerminal` now happens under the `_terminal`'s write lock * Certain things that InitializeTerminal were calling themselves attempted to take the lock. They no longer do so. * TermControlAutomationPeer cannot take the read lock, because setting the scrollbar's `Maximum` during `InitializeTerminal` will trigger vivification of the automation peer tree; if it attempts to take the lock it will deadlock during initialization. * `BlinkCursor` was renamed to `CursorTimerTick` because it's the "Tick" handler for the "CursorTimer". * `DragDropHandler` was converted into a coroutine instead of just _calling_ a coroutine. Caveats: Terminal may not have a `_buffer` until InitializeTerminal happens. There's a nasty coupling between RenderTarget and TextBuffer that means that we need to have a renderer before we have a buffer. There's a second nasty coupling between RenderThread and Renderer: we can't create a RenderThread during construction because it needs to be given a renderer, and we can't create a Renderer during construction because it needs a RenderThread. We don't want to kick off a thread during construction. Testing: I wailed on this by opening and closing and resizing terminals and panes and tabs, up to a hundred open tabs and one tab with 51 panes. I set one tab to update the title as fast as it possibly could and tested teardown, zoom, resize, mouse movement, etc. while this was all happening. Closes #4613.
- Loading branch information