E-book viewer: Fix a regression that caused a spurious error on Windows when reading out selected text

This commit is contained in:
Kovid Goyal 2023-02-06 18:47:29 +05:30
parent 9531c86117
commit d0cbe42b30
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -76,10 +76,12 @@ class Client:
self.backend.speak(self.current_chunks[self.current_chunk_idx], is_cued=True)
def handle_event(self, x):
if isinstance(x, MarkReached) and self.current_chunks:
if isinstance(x, MarkReached):
if self.current_chunks:
self.last_mark = x.id
self.callback_ignoring_errors(Event(EventType.mark, x.id))
elif isinstance(x, MediaStateChanged) and self.current_chunks:
elif isinstance(x, MediaStateChanged):
if self.current_chunks:
if x.state is MediaState.ended:
if self.current_chunk_idx >= len(self.current_chunks) - 1:
self.clear_chunks()
@ -102,8 +104,10 @@ class Client:
raise KeyError(f'Unknown event type: {x}')
def speak_simple_text(self, text):
self.current_callback = None
self.backend.pause()
self.clear_chunks()
self.current_callback = None
if text:
self.backend.speak(text)
def speak_marked_text(self, text, callback):