Fix, ids in view manager are not stable#196
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughView gained an explicit integer id stored in ChangesView ID Lifecycle Management
sequenceDiagram
participant Manager
participant ViewD3D11
participant View
Manager->>Manager: ++_id
Manager->>ViewD3D11: CreateView(++_id, renderer, manager)
ViewD3D11->>View: View(id, renderer, manager)
View->>View: store _id
Manager->>Manager: push view to _views
Manager->>Manager: return _id
Manager->>Manager: DestroyView(id)
Manager->>Manager: find view by GetId() == id
Manager->>Manager: erase matched view
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 `@code/framework/src/gui/manager.cpp`:
- Around line 148-149: The change that returns a monotonic view id (++_id) in
the view creation path (where ViewD3D11 is constructed) no longer matches how
GetView(int id) looks up views by directly indexing _views[id], causing
out-of-bounds access; fix by making the lookup consistent: either return the
vector index (use _id before increment or don't increment) or update GetView(int
id) to locate views by their stable id (e.g., maintain a mapping from viewId ->
vector index or search _views for view->Id() and return that pointer). Adjust
the creation code that assigns ids (the ++_id / ViewD3D11 construction) and/or
add/maintain an _viewIndexMap (or change GetView to linear search) so
GetView(int id) uses the same id semantics as the creator.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 19908997-7ab1-4575-8d1b-f72d7050bb59
📒 Files selected for processing (6)
code/framework/src/gui/backend/view_d3d11.cppcode/framework/src/gui/backend/view_d3d11.hcode/framework/src/gui/manager.cppcode/framework/src/gui/manager.hcode/framework/src/gui/view.cppcode/framework/src/gui/view.h
Fixes issue where you create multiple views and destroy them in different order
Summary by CodeRabbit