mirror of
https://github.com/yusufipk/dikte.git
synced 2026-09-12 03:16:19 +00:00
Keep the rebuild away from a window a thread is still writing to
deleteLater destroyed a window whose model boxes a daemon thread was still reporting into: a running download died with a RuntimeError, the .part stayed on disk and the UI said nothing. Dropping the reference is how the ordinary close path lets a window go, and the closures a thread holds keep the object alive until it is done, so the rebuild now does the same. While the transcriber or either model box is working the rebuild is skipped altogether; _built_language keeps the old language, so the next quiet save asks for it by itself. The new window is also placed and turned to the old tab before it is shown, so it no longer comes up at the default size and jumps. And tests/test_ui.py now says that a save with a changed language emits language_changed, and one without does not.
This commit is contained in:
+14
-1
@@ -1804,9 +1804,22 @@ class SettingsWindow(QDialog):
|
||||
# waits until the box is dismissed, so the window is not pulled out
|
||||
# from under a dialog it is holding up.
|
||||
QMessageBox.information(self, t("Dikte Settings"), t("Saved successfully."))
|
||||
if i18n.language() != self._built_language:
|
||||
if i18n.language() != self._built_language and not self._work_in_flight():
|
||||
self.language_changed.emit()
|
||||
|
||||
def _work_in_flight(self):
|
||||
"""A daemon thread of this window's is still running.
|
||||
|
||||
Replacing the window now would let it be collected, taking the C++
|
||||
side of the model boxes down with it, and the thread's next progress
|
||||
report would land on a deleted object. The stale labels stand until a
|
||||
later save finds the window quiet; _built_language keeps the old
|
||||
language, so that save asks for the rebuild by itself.
|
||||
"""
|
||||
return (self.transcriber.busy
|
||||
or self.local_whisper._downloading
|
||||
or self.local_llm._downloading)
|
||||
|
||||
@staticmethod
|
||||
def _select_data(combo, value):
|
||||
index = combo.findData(value)
|
||||
|
||||
Reference in New Issue
Block a user