Skip to content

[GUI] Parse the dialog style sheet afresh so a dialog never inherits another one's - #778

Closed
arnodelorme wants to merge 1 commit into
developfrom
agent/fix-stale-stylesheet
Closed

arnodelorme wants to merge 1 commit into
developfrom
agent/fix-stale-stylesheet

Conversation

@arnodelorme

@arnodelorme arnodelorme commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

develop fails test_disabled_list_box_is_greyed on every platform, which blocks the other pull requests. Qt caches a dialog's parsed style sheet by its address and drops it only when a polished dialog is destroyed. A dialog styled but never shown leaves its sheet behind, and a new dialog at the same address was drawn with it. The dialog is now polished and its sheet set again, which makes Qt parse it. This replaces an unpolish call that Qt ignores on a fresh dialog.

Fixes #779
Part of #745

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

🤖 Why this is needed now, and the evidence.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @arnodelorme's task in 1m 3s —— View job


Code review

  • Checked that the PR is open, not a draft, has not been reviewed yet, and that HEAD matches the PR head (6f29e7b)

  • Read the diff, the build_dialog caller, the other places that set a style sheet, and the regression test

  • Posted the review

  • Overall assessment: Safe to merge. The fix does what the description says. After the dialog is polished, the second setStyleSheet call makes Qt re-read the sheet and throw away the old parsed copy at that address. The leftover copy comes from a styled dialog that was never shown and was destroyed, and that copy is gone now. build_dialog (qt.py:207) applies the style before the dialog has any child widgets or layout. So ensurePolished() only touches the empty dialog, and setting the sheet a second time costs almost nothing.

  • Highest-risk area: other dialogs that set a style sheet before they are shown (see Nits).

  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

  • The fix covers one place. The leftover copy is created when a sheet is set on a widget that is never polished. Qt only clears a widget's cached sheet when it is destroyed if the widget was polished first. This PR fixes the dialog that reads the leftover, and only in _apply_eeglab_style. These spots also set a sheet before the widget is shown and could still pick up a leftover if a new widget lands at a reused address:

    • listdlg2._apply_listdlg_style
    • plugin_menu.py:569
    • theme.append_eeglab_floating_dialog_style
    • coregister.py:206

    This PR doesn't need to handle them to unblock develop. If the problem comes back, the more general fix is to polish every styled widget, starting with build_listdlg2_dialog. A polished widget clears its own cached sheet when it is destroyed.

Test gaps

None. tests/test_guifunc_primitives.py::test_disabled_list_box_is_greyed already serves as the regression test: on develop it fails after the earlier test_listdlg2_* builds. I couldn't run it in this session because the pytest command needed approval, so the CI result is the evidence.

EEGLAB parity notes

None. This is a Qt rendering fix, and nothing EEGLAB users see changes.

I checked for correctness bugs, EEGLAB parity, data structure compatibility, tests for the changed behavior, and compliance with CLAUDE.md and AGENTS.md. I couldn't post this as a separate review comment with gh pr comment because writing the comment body to a temporary file needed approval, so the review is in this comment.

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Review (Claude Fable): needs Arno

Details

What I ran (Mac, Python 3.12, PySide6 with Qt 6.11, offscreen)

Tree test_file_menu_audit_673.py + test_guifunc_primitives.py
Old base 395f19ed (before this branch) test_disabled_list_box_is_greyed fails
This branch 6f29e7bb passes
develop 1a74fb97 (has #805) passes
develop + this change, conflict resolved by hand passes
  • Nine GUI test files on develop and on develop + this change: 285 passed, 1 skipped, 1 failed in both. The one failure is local only (defusedxml is not installed on this Mac).
  • The 46 capture_*_dialog functions of tools/visual_parity/visual_capture.py, rendered on develop and on develop + this change: 46 of 46 files identical byte for byte. So no capture is needed for this pull request, but the body should say so (rule 27). Today that evidence sits in a comment, not in the body.
  • CI on this head: every job passed on November 27, against the old base. GitHub now reports the branch as conflicting.

The conflict. #805 deleted the same unpolish lines this branch replaces. The resolution is to keep develop's setStyleSheet line and add ensurePolished() plus the second setStyleSheet. No other open pull request touches these lines (#835, #844, #846, #848 and #851 edit other parts of qt.py).

Is it still needed after #805? The two fixes work at opposite ends. #805 polishes the list selector early, so that dialog no longer leaves a sheet behind. This one makes every inputgui dialog drop whatever was left at its address. What could still leave a sheet behind on develop is a styled dialog that is built and thrown away without ever being shown. That happens in tests and capture scripts, not in a user session.

I tried to provoke the defect on develop in a loop: 60 dialogs built and destroyed unshown, then a new inputgui dialog with a disabled list box, 40 times, with three kinds of earlier dialog (plain Qt, inputgui with an extra sheet, listdlg2). The new dialog landed on a freed address in 8 to 29 of 40 trials and was drawn correctly 120 times out of 120. One limit: the same loop also draws correctly on the old base, where pytest fails, so this loop is not a sensitive test. It shows no sign of a remaining defect. It does not prove there is none.

On the explanation. A plain Qt script (dialog A styled and destroyed unshown, dialog B at the same address with another sheet) drew B correctly in 60 trials out of 60 with no fix at all, 38 of them on a reused address. So "same address, old sheet" is not the whole story. The failure needs something more that neither this pull request nor #805 pins down, and neither one has a test that fails on purpose. That is one more reason not to stack a second fix on a cause that is only partly understood.

Cost if kept. The style sheet of every dialog is parsed twice and the dialog is polished before its children exist. I saw no visible effect (46 identical renderings, same test results). The 4-line comment in the code describes Qt internals that I could not confirm with the script above, so it should be shortened to what is known.

Rules. Rule 21 (small, one fix): met. Rule 34 (fix shared code, not each window): met, _apply_eeglab_style serves every inputgui dialog. Rules 23 and 26 do not apply, no layout changes. Rule 33: #779 is closed with #805 named, as it should be.

— orchestrator review

@arnodelorme

Copy link
Copy Markdown
Collaborator Author

Closed as superseded by #805, as Arno approved (November 28, 2026). — orchestrator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

supergui: develop fails test_disabled_list_box_is_greyed in the full suite, a dialog is drawn with an earlier dialog's style sheet

1 participant