fix(v3/windows): guard FillRect against nil client rect in WM_ERASEBKGND#5687
Conversation
GetClientRect can return nil during minimise/restore transitions; passing that to FillRect crashes. Guard before painting the solid background. Salvaged from #5636 (reported by @sinspired); the rest of that PR was superseded by #5596/#5616.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a nil check in the Windows ChangesWindows repaint crash guard
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@v3/pkg/application/webview_window_windows.go`:
- Around line 1634-1638: The nil check in the paint path is ineffective because
`w32.GetClientRect` in `user32.go` panics on failure and never returns nil on
success, so the minimize/restore case still crashes before `FillRect` runs. Fix
this at the wrapper boundary by adding a non-panicking client-rect helper such
as `TryGetClientRect` or `GetClientRectOK` that returns both the `RECT` and a
success flag, then update the `w.hwnd` rendering code to use that helper and
skip painting when the call fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8adc84a0-b907-44f1-a828-957f30a455b8
📒 Files selected for processing (2)
v3/UNRELEASED_CHANGELOG.mdv3/pkg/application/webview_window_windows.go
During minimise/restore transitions
GetClientRectcan legitimately return nil; passing that toFillRectcrashes when painting the solid background inWM_ERASEBKGND. This guards the call.Salvaged from #5636 — that PR's main change (moving
resizePendingto a per-window field) was superseded by #5596 (which removed the resize-debounce mechanism entirely) and #5616, but this nil-rect guard was a genuine, still-unfixed hardening. Credit to @sinspired for spotting it.Builds clean for
GOOS=windows.Summary by CodeRabbit