mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Fix race condition during shutdoen under Windows (#2864)
The terminal writer thread could send escape sequences when the terminal was unable to process then; i.e. when not in virtual mode. The following fixes have been made. - Switch the terminal to virtual mode before the writer thread is started and any control sequences are queued to the writer thread. - Wait for the writer thread to finish before switching the terminal out of virtual mode.
This commit is contained in:
@@ -76,11 +76,11 @@ class WindowsDriver(Driver):
|
||||
"""Start application mode."""
|
||||
loop = asyncio.get_running_loop()
|
||||
|
||||
self._restore_console = win32.enable_application_mode()
|
||||
|
||||
self._writer_thread = WriterThread(self._file)
|
||||
self._writer_thread.start()
|
||||
|
||||
self._restore_console = win32.enable_application_mode()
|
||||
|
||||
self.write("\x1b[?1049h") # Enable alt screen
|
||||
self._enable_mouse_support()
|
||||
self.write("\x1b[?25l") # Hide cursor
|
||||
@@ -110,8 +110,6 @@ class WindowsDriver(Driver):
|
||||
"""Stop application mode, restore state."""
|
||||
self._disable_bracketed_paste()
|
||||
self.disable_input()
|
||||
if self._restore_console:
|
||||
self._restore_console()
|
||||
|
||||
# Disable alt screen, show cursor
|
||||
self.write("\x1b[?1049l" + "\x1b[?25h")
|
||||
@@ -121,3 +119,5 @@ class WindowsDriver(Driver):
|
||||
"""Perform cleanup."""
|
||||
if self._writer_thread is not None:
|
||||
self._writer_thread.stop()
|
||||
if self._restore_console:
|
||||
self._restore_console()
|
||||
|
||||
Reference in New Issue
Block a user