fix(canvas): eliminate screenChanged disconnect RuntimeWarning#116
Merged
Conversation
…connect warning
PR-J's DPR change handler called disconnect+connect on every showEvent,
which raised a RuntimeWarning ("Failed to disconnect from signal
screenChanged") on the first show and any re-show where the signal
was never actually connected. PySide6 6.11 emits a RuntimeWarning
(not an exception) for the "signal was never connected" case, so
contextlib.suppress(TypeError, RuntimeError) could not silence it.
Now showEvent tracks the previously-connected window in
_screen_signal_window and only disconnects when the window actually
changes (e.g., widget was reparented to a different top-level).
First show, same-window re-show, and reparent are all handled
without the warning.
Applied identically to _SelectCanvas (viewer) and PdfEditCanvas (editor).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR-J (R8/D1 DPR change handler) added a disconnect-then-connect pattern in
showEventfor both the viewer canvas and editor canvas. On PySide6 6.11, callingdisconnecton a signal that was never connected (first show, or re-show after teardown) emits:contextlib.suppress(TypeError, RuntimeError)doesn't silence a warning — Python warnings and exceptions are separate.Fix
Instead of blindly disconnecting on every show, both canvases now track the currently-connected window in
self._screen_signal_window:Applied identically in
_SelectCanvas.showEvent(app/viewer/canvas.py) andPdfEditCanvas.showEvent(app/editor/canvas.py). Kept inline (~10 lines each) rather than extracting a helper — factoring acrossviewer+editorpackages had marginal gain.Tests
tests/test_screen_changed_binding.py— 8 source-level regressions:__init__methodswin is prev_winAlso verified that the existing R8/D1 tests (
test_round8_fixes.py::test_{viewer,editor}_canvas_handles_screen_changed) still pass — no regression on the DPR change handling behaviour.Validation
APP_VERSIONbumpNot related to PR #115
PR #115 (presentation mode HUD icons) touches the same files but different lines. Merge order doesn't matter; either can go first.