From 29cfdf9507ceb86b82c90c9d20b3127f2fde96a7 Mon Sep 17 00:00:00 2001 From: Jiaxing Hu Date: Fri, 30 Oct 2026 20:17:09 +1300 Subject: [PATCH 1/3] smoke: log each check's time; dump stacks before CI's timeout The macOS job on #79 hung after the search window opened and CI killed it at 15 minutes with no clue where: stdout is buffered until the end. Each check now logs its name and time to stderr as it finishes, and faulthandler dumps every thread's stack and exits at 13 minutes. --- tests/smoke.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/smoke.py b/tests/smoke.py index b0d0397..ecc023e 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -14,6 +14,7 @@ pip install . && python tests/smoke.py """ +import faulthandler import os import stat import sys @@ -3128,7 +3129,26 @@ def run_window(app, lang): app.processEvents() +def _timed(check): + """Log each check and how long it took to stderr, which CI shows as it + happens (stdout is buffered until the end).""" + def run(*args): + start = time.monotonic() + try: + return check(*args) + finally: + print(f"[smoke] {check.__name__} {time.monotonic() - start:.1f}s", file=sys.stderr, flush=True) + run.__name__ = check.__name__ + return run + + def main(): + # CI stops the job at 15 minutes with no clue where it hung: dump every + # thread's stack before that and exit. + faulthandler.dump_traceback_later(13 * 60, exit=True) + for name, value in list(globals().items()): + if name.startswith("check_") and callable(value): + globals()[name] = _timed(value) app = QApplication(sys.argv) app.setOrganizationName(app_settings.ORGANIZATION) app.setApplicationName(app_settings.APPLICATION) From e010aa1bf657b0fc1eb6db30e65199481e9e0d65 Mon Sep 17 00:00:00 2001 From: Jiaxing Hu Date: Fri, 30 Oct 2026 20:36:22 +1300 Subject: [PATCH 2/3] Size the tabs by the current page without asking every page #76 gave CurrentPageTabWidget a minimumSizeHint that asked every page for its minimum on each call. Layout asks for it on every pass, and a theme change relayouts the whole window, so on CI's macOS runner one check took 338 s and the next hung until the job was killed (the stack dump from the previous commit: sizeHint under apply_theme). _resize_tabs_to_current already gives non-current pages an Ignored vertical policy so they don't count; give them an Ignored horizontal policy too, and drop the override. --- rkdeveloptool-gui/rkdevtoolgui.py | 15 ++++++++------- rkdeveloptool-gui/widgets.py | 14 -------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/rkdeveloptool-gui/rkdevtoolgui.py b/rkdeveloptool-gui/rkdevtoolgui.py index 5960d43..9fa9572 100644 --- a/rkdeveloptool-gui/rkdevtoolgui.py +++ b/rkdeveloptool-gui/rkdevtoolgui.py @@ -672,19 +672,20 @@ def create_right_panel(self): return panel def _resize_tabs_to_current(self, index): - """Make the tab widget take the height of the current tab only. + """Make the tab widget take the size of the current tab only. - Non-current pages get an Ignored vertical size policy so they don't - inflate the tab widget's size hint; the current page uses its natural - height. This keeps short tabs compact and lets the log panel fill the - rest of the column. + Non-current pages get Ignored size policies so they don't inflate + the tab widget: in height, short tabs stay compact and the log panel + fills the rest of the column; in width, the two-column Settings page + no longer makes every tab wider than the panel at the default + window size. """ for i in range(self.tab_widget.count()): page = self.tab_widget.widget(i) if page is None: continue - vpol = QSizePolicy.Policy.Preferred if i == index else QSizePolicy.Policy.Ignored - page.setSizePolicy(QSizePolicy.Policy.Preferred, vpol) + policy = QSizePolicy.Policy.Preferred if i == index else QSizePolicy.Policy.Ignored + page.setSizePolicy(policy, policy) # CurrentPageTabWidget sizes itself from the current page; let the # layout re-ask. (No adjustSize() on the page: that shrank it to its # size hint for a frame before the layout stretched it back, which diff --git a/rkdeveloptool-gui/widgets.py b/rkdeveloptool-gui/widgets.py index 8f6f2aa..fd9bc97 100644 --- a/rkdeveloptool-gui/widgets.py +++ b/rkdeveloptool-gui/widgets.py @@ -26,20 +26,6 @@ def sizeHint(self): return hint return QSize(hint.width(), page.sizeHint().height() + self._chrome(page)[1]) - def minimumSizeHint(self): - # Likewise the width: the widest page (Settings, two columns) made - # every tab that wide, and the right panel scrolled sideways at the - # default window size. - hint = super().minimumSizeHint() - page = self.currentWidget() - if page is None: - return hint - # The frame's share: the stock minimum less its widest page's. - widest = max(self.widget(i).minimumSizeHint().width() for i in range(self.count())) - frame = max(hint.width() - widest, 0) - width = max(page.minimumSizeHint().width() + frame, self.tabBar().minimumSizeHint().width()) - return QSize(width, hint.height()) - def heightForWidth(self, width): # Pages with word-wrapped labels make the whole column height-for- # width, and then the scroll area sizes it from this - which Qt also From c8b7ee40e1dfbca5f0000fdd8cd2d59a7ebacd9b Mon Sep 17 00:00:00 2001 From: Jiaxing Hu Date: Fri, 30 Oct 2026 20:45:35 +1300 Subject: [PATCH 3/3] Re-apply the system theme only when it changes With the theme on Auto, a timer calls apply_system_theme every 2 s, and it restyled the whole app each time (app.setStyle, a relayout of every widget) whether or not the system's theme had changed. The app was busy for nothing every 2 s, and on CI's macOS runner a restyle took longer than 2 s, so the next poll came before the last finished and the smoke test never got idle: the hang under apply_theme in the stack dump. It now applies only when the system's theme differs from the last one applied; picking Auto in the menu still applies it right away. --- rkdeveloptool-gui/rkdevtoolgui.py | 2 +- rkdeveloptool-gui/themes.py | 12 ++++++++++-- tests/smoke.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/rkdeveloptool-gui/rkdevtoolgui.py b/rkdeveloptool-gui/rkdevtoolgui.py index 9fa9572..da5114c 100644 --- a/rkdeveloptool-gui/rkdevtoolgui.py +++ b/rkdeveloptool-gui/rkdevtoolgui.py @@ -820,7 +820,7 @@ def on_theme_changed(self): # Enable automatic theme detection if hasattr(self, 'theme_auto_manager'): self.theme_auto_manager.enable_auto = True - self.theme_auto_manager.apply_system_theme() + self.theme_auto_manager.apply_system_theme(force=True) elif selected_theme: # Disable auto and apply selected theme if hasattr(self, 'theme_auto_manager'): diff --git a/rkdeveloptool-gui/themes.py b/rkdeveloptool-gui/themes.py index 7149a01..a43d526 100644 --- a/rkdeveloptool-gui/themes.py +++ b/rkdeveloptool-gui/themes.py @@ -382,8 +382,9 @@ def _get_windows_theme(self): except Exception: return "light" - def apply_system_theme(self): - """Apply system theme to the application""" + def apply_system_theme(self, force=False): + """Apply the system theme when it has changed (or when forced: on + start-up, and when the user picks Auto).""" if not self.enable_auto: return @@ -392,6 +393,13 @@ def apply_system_theme(self): return theme = self.get_system_theme() + # The poll runs every 2 s. Applying a theme restyles and relays out + # every widget in the app, so doing it each time kept the window + # busy for nothing, and on a slow machine (CI's macOS runner) the + # next poll came before the last one finished and it never idled. + if theme == getattr(self, "_applied", None) and not force: + return + self._applied = theme # Leave the picker on "Auto". Moving it to Dark/Light hid that auto # mode was on, and picking that same theme afterwards changed nothing, diff --git a/tests/smoke.py b/tests/smoke.py index ecc023e..22be7be 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -3116,6 +3116,33 @@ def yes_text(): errors.append(f"Qt's Yes button in Chinese reads {zh!r} (English {en!r})") +def check_theme_poll(app): + """The 2-second system-theme poll restyles the app only when the + system's theme changed; doing it every time kept slow machines busy.""" + window = RKDevToolGUI(TranslationManager(lang="en", settings=AppSettings()), + settings=AppSettings()) + window.stop_device_detection() + auto = window.theme_auto_manager + applied, system = [], ["dark"] + real = (window.theme_manager.apply_theme, auto.get_system_theme) + window.theme_manager.apply_theme = lambda theme=None, style=None: applied.append(theme) + auto.get_system_theme = lambda: system[0] + auto.enable_auto = True + try: + auto.apply_system_theme(force=True) + auto.apply_system_theme() + auto.apply_system_theme() + system[0] = "light" + auto.apply_system_theme() + if applied != ["dark", "light"]: + errors.append(f"theme poll applied {applied}") + finally: + window.theme_manager.apply_theme, auto.get_system_theme = real + window.cleanup() + window.deleteLater() + app.processEvents() + + def run_window(app, lang): settings = AppSettings() manager = TranslationManager(lang=lang, settings=settings) @@ -3162,6 +3189,7 @@ def main(): check_translations() check_qt_translation(app) + check_theme_poll(app) check_partition_backup(app) check_first_run_wizard(app) check_maskrom_help(app)