fix(color): fix issues with quick menu, favorites and key shortcuts#7351
fix(color): fix issues with quick menu, favorites and key shortcuts#7351philmoz wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR refactors hardware key event handling across the UI framework by consolidating per-button press/long-press handlers into a unified ChangesHardware Key Shortcut Dispatch and Quick Menu Updates
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
radio/src/gui/colorlcd/model/model_select.cpp (1)
546-549: ⚡ Quick winAvoid forwarding through the page being closed.
Line 546 snapshots
navWindow()beforeonCancel(), so Line 549 can dispatch back through the currentModelLabelsWindowafter it has already been marked_deleted. Re-resolve the active nav window after closing instead of using the stale pointer.Proposed change
QMPage pg = g_eeGeneral.getKeyShortcut(event); if (pg != QM_MANAGE_MODELS) { - auto p = navWindow(); - if (p) { - onCancel(); - p->doKeyShortcut(event); - } + onCancel(); + auto top = Window::topWindow(); + if (top && top->isNavWindow()) { + static_cast<NavWindow*>(top)->doKeyShortcut(event); + } } }🤖 Prompt for 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. In `@radio/src/gui/colorlcd/model/model_select.cpp` around lines 546 - 549, The code captures navWindow() into p before calling onCancel(), which may mark the current ModelLabelsWindow as _deleted and cause p->doKeyShortcut(event) to dispatch through a stale window; instead, call onCancel() first and then re-query navWindow() (e.g., auto p2 = navWindow()) and call p2->doKeyShortcut(event) only if p2 is non-null, ensuring you do not forward events through the page that was just closed (references: navWindow(), onCancel(), doKeyShortcut(event), ModelLabelsWindow, _deleted).radio/src/gui/colorlcd/libui/page.cpp (1)
142-145: ⚡ Quick winResolve the target nav window after closing the page.
Line 142 captures the current
NavWindowbeforeonCancel(), so on a regular page this is usuallythis. Line 145 then re-entersdoKeyShortcut()on a window already marked_deleted, which currently works only becausedeleteLater()is deferred.Proposed change
if (pg == QM_OPEN_QUICK_MENU) { QuickMenu::openQuickMenu(); } else { - auto p = navWindow(); - if (p) { - onCancel(); - p->doKeyShortcut(event); - } + onCancel(); + auto top = Window::topWindow(); + if (top && top->isNavWindow()) { + static_cast<NavWindow*>(top)->doKeyShortcut(event); + } } }🤖 Prompt for 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. In `@radio/src/gui/colorlcd/libui/page.cpp` around lines 142 - 145, The code captures the NavWindow via navWindow() into p before calling onCancel(), which can mark the page deleted and leave p pointing to a deleted window; instead, call onCancel() first and then re-resolve the target NavWindow by calling navWindow() again (e.g., p = navWindow()) and only then invoke p->doKeyShortcut(event); also guard the re-resolved pointer for null/invalid/_deleted state before calling doKeyShortcut to avoid re-entering a deleted window.
🤖 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 `@radio/src/gui/colorlcd/setup_menus/quick_menu.cpp`:
- Around line 325-335: The favorites validation is comparing against the stale
instance state curPage instead of the requested page newCurPage; change the loop
check to compare favoritesMenuItems[i].qmPage to newCurPage (the page being
opened) and, if not found, clear the pending group and reset newCurPage to
QM_NONE (instead of mutating curPage). Update the block that touches
newPageGroup/ICON_QM_FAVORITES/favoritesMenuItems so validation uses newCurPage
and only assign curPage after this validation passes.
---
Nitpick comments:
In `@radio/src/gui/colorlcd/libui/page.cpp`:
- Around line 142-145: The code captures the NavWindow via navWindow() into p
before calling onCancel(), which can mark the page deleted and leave p pointing
to a deleted window; instead, call onCancel() first and then re-resolve the
target NavWindow by calling navWindow() again (e.g., p = navWindow()) and only
then invoke p->doKeyShortcut(event); also guard the re-resolved pointer for
null/invalid/_deleted state before calling doKeyShortcut to avoid re-entering a
deleted window.
In `@radio/src/gui/colorlcd/model/model_select.cpp`:
- Around line 546-549: The code captures navWindow() into p before calling
onCancel(), which may mark the current ModelLabelsWindow as _deleted and cause
p->doKeyShortcut(event) to dispatch through a stale window; instead, call
onCancel() first and then re-query navWindow() (e.g., auto p2 = navWindow()) and
call p2->doKeyShortcut(event) only if p2 is non-null, ensuring you do not
forward events through the page that was just closed (references: navWindow(),
onCancel(), doKeyShortcut(event), ModelLabelsWindow, _deleted).
🪄 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 Plus
Run ID: f0c4c83a-a332-4063-8ce1-3c8b431e692f
📒 Files selected for processing (28)
radio/src/edgetx.cppradio/src/gui/colorlcd/libui/page.cppradio/src/gui/colorlcd/libui/page.hradio/src/gui/colorlcd/libui/window.cppradio/src/gui/colorlcd/libui/window.hradio/src/gui/colorlcd/mainview/view_main.cppradio/src/gui/colorlcd/mainview/view_main.hradio/src/gui/colorlcd/model/function_switches.cppradio/src/gui/colorlcd/model/model_heli.cppradio/src/gui/colorlcd/model/model_select.cppradio/src/gui/colorlcd/model/model_select.hradio/src/gui/colorlcd/model/model_setup.cppradio/src/gui/colorlcd/model/model_usbjoystick.cppradio/src/gui/colorlcd/model/preflight_checks.cppradio/src/gui/colorlcd/model/throttle_params.cppradio/src/gui/colorlcd/model/timer_setup.cppradio/src/gui/colorlcd/model/trainer_setup.cppradio/src/gui/colorlcd/module/module_setup.cppradio/src/gui/colorlcd/radio/preview_window.cppradio/src/gui/colorlcd/radio/radio_setup.cppradio/src/gui/colorlcd/setup_menus/key_shortcuts.cppradio/src/gui/colorlcd/setup_menus/pagegroup.cppradio/src/gui/colorlcd/setup_menus/pagegroup.hradio/src/gui/colorlcd/setup_menus/quick_menu.cppradio/src/gui/colorlcd/setup_menus/quick_menu.hradio/src/gui/colorlcd/setup_menus/quick_menu_favorites.cppradio/src/gui/colorlcd/setup_menus/quick_menu_group.cppradio/src/gui/colorlcd/setup_menus/quick_menu_group.h
💤 Files with no reviewable changes (4)
- radio/src/gui/colorlcd/setup_menus/quick_menu_group.h
- radio/src/edgetx.cpp
- radio/src/gui/colorlcd/mainview/view_main.cpp
- radio/src/gui/colorlcd/setup_menus/pagegroup.cpp
Fixes:
3.0 only.
Summary by CodeRabbit
New Features
Bug Fixes
UI/UX Updates