Fixed degenerate shapes when adding a mapping right after video import#627
Open
sofian wants to merge 1 commit into
Open
Fixed degenerate shapes when adding a mapping right after video import#627sofian wants to merge 1 commit into
sofian wants to merge 1 commit into
Conversation
aalex
approved these changes
Jul 27, 2026
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
Stacks on #625. Importing a video and immediately adding a shape (e.g. a circle) for it could create a degenerate shape with all control points collapsed near the same point. Root cause: #625 made video import asynchronous, so right after import
Video::getWidth()/getHeight()can still report -1 (no frame decoded yet) — and shape-creation (Util::createEllipseForTexture()etc.) reads those synchronously at the moment the user clicks "Add Ellipse". This is exactly the case the old blockingwaitForNextBits()used to paper over by guaranteeing valid dimensions before returning.Fix follows the same pattern already used for Syphon sources in this codebase:
Video::getWidth()/getHeight()now fall back to a saneDEFAULT_WIDTH/DEFAULT_HEIGHT(640×480) placeholder instead of the raw (possibly -1) value from the underlying player, so a shape created before any frame arrives is never degenerate.Video::frameSizeKnown(sourceId, width, height)signal, emitted once the first real frame arrives.MainWindow::autoFitVideoInputShapes()(mirroring the existingautoFitSyphonInputShapes()) rescales any input shape still at the untouched default size once the real resolution is known, without touching shapes the user has already adjusted.Test plan
qmake6 mapmap.pro && makebuilds cleantests/suite builds and all 44 existing Qt Test cases passgetWidth()/getHeight()return 640×480 immediately after construction (not -1×-1), andframeSizeKnownfires with the real dimensions (tested with an 800×600 source) once the frame arrives