Skip to content

fix: idisp() crashes when reuse=True with no title given - #94

Merged
petercorke merged 1 commit into
mainfrom
fix/idisp-reuse-no-title
Aug 15, 2026
Merged

petercorke merged 1 commit into
mainfrom
fix/idisp-reuse-no-title

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

  • Image.disp(reuse=True, matplotlib=False) with no title= given crashes with a bare AssertionError, instead of opening/reusing a window.
  • Root cause: the OpenCV display path only auto-generates a window title when reuse=False (if not reuse and title is None: ...). With reuse=True and no explicit title, title stays None, and the very next line's assert title is not None (added later, with a comment claiming this was already guaranteed -- it wasn't, for this exact case) fails.
  • reuse=True is meant for an animation loop redrawing into the same window across many calls, so the fallback can't be the existing counter-incremented "idisp.N" naming (that opens a new window per call, defeating reuse). Uses a fixed generic title instead, so repeated calls without an explicit title still share one window.

Test plan

  • tests/base/test_io.py::TestIdisp::test_idisp_reuse_no_title (new) -- two consecutive reuse=True calls with no title, must not raise
  • Full test suite: no regressions
  • Manually verified against RVC3-python's chap14.ipynb notebook (visual odometry loop, image.disp(reuse=True, fps=20, matplotlib=False))

🤖 Generated with Claude Code

The OpenCV display path only auto-generated a window title when
reuse=False -- `if not reuse and title is None: ...` -- so
reuse=True with no explicit title left title as None, and the very
next line's `assert title is not None` (added later, with a comment
claiming this was already guaranteed) crashed with a bare
AssertionError instead of ever reaching cv2.namedWindow().

reuse=True is meant for an animation loop redrawing into the same
window across many calls, so the fallback can't be the existing
counter-incremented "idisp.N" (that would open a new window per call,
defeating reuse) -- use a fixed generic title instead, so repeated
calls without an explicit title still share one window.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 8d64233 into main Aug 15, 2026
29 checks passed
@petercorke
petercorke deleted the fix/idisp-reuse-no-title branch October 3, 2026 14:47
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.

1 participant