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:
2026-08-27 15:13:54 +03:00
parent e681accc90
commit a3bb5ed29b
3 changed files with 50 additions and 9 deletions
+15
View File
@@ -240,6 +240,21 @@ class Settings(DikteTest):
with self.subTest(key=key):
self.assertEqual(stored[key], value)
def test_only_a_save_that_changed_the_language_says_so(self):
# The owner answers language_changed by replacing the window, so a
# save that left the language alone must keep quiet.
i18n = settings_ui.i18n
self.addCleanup(i18n.set_language, i18n.language())
window = self.window(cfg.Config())
heard = []
window.language_changed.connect(lambda: heard.append(True))
window._save()
self.assertEqual(heard, [])
other = "en" if i18n.language() == "tr" else "tr"
window._select_data(window.ui_language, other)
window._save()
self.assertEqual(heard, [True])
def test_the_model_box_on_screen_belongs_to_whoever_cleans_up(self):
"""An OpenRouter id and a Claude alias are not the same field."""
window = self.window(cfg.Config())