Fix Preferences apply silently discarding changes when a page fails to instantiate#33842
Fix Preferences apply silently discarding changes when a page fails to instantiate#33842manolo wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughTwo null-safety fixes are applied to the Preferences QML components. In 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsLinked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/preferences/qml/MuseScore/Preferences/PreferencesDialog.qml (1)
116-120:⚠️ Potential issue | 🟠 Major | ⚡ Quick winGuard reset calls for missing page objects, same as apply path.
Line 119 calls
obj.reset()unconditionally. In the same null-instantiation scenario,objisundefined, so reset can still throw and abort the action flow.Suggested fix
for (var i in pages) { var page = pages[i] var obj = root.prv.pagesObjects[page.id] - obj.reset() + if (obj) { + obj.reset() + } }🤖 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 `@src/preferences/qml/MuseScore/Preferences/PreferencesDialog.qml` around lines 116 - 120, The unconditional call to obj.reset() on line 119 will throw an error and abort the action flow when obj is undefined in the null-instantiation scenario. Add a guard condition to check if obj is defined before calling obj.reset(), similar to the pattern used in the apply path, to ensure reset is only called on valid page objects.
🤖 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.
Outside diff comments:
In `@src/preferences/qml/MuseScore/Preferences/PreferencesDialog.qml`:
- Around line 116-120: The unconditional call to obj.reset() on line 119 will
throw an error and abort the action flow when obj is undefined in the
null-instantiation scenario. Add a guard condition to check if obj is defined
before calling obj.reset(), similar to the pattern used in the apply path, to
ensure reset is only called on valid page objects.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b4c807a3-8d53-4708-8c0b-99a386f23db9
📒 Files selected for processing (2)
src/preferences/qml/MuseScore/Preferences/PreferencesDialog.qmlsrc/preferences/qml/MuseScore/Preferences/PreferencesPage.qml
…o instantiate Guard obj before calling apply() in PreferencesDialog to prevent a TypeError on undefined from corrupting the ok accumulator. Also null-safe parent binding in PreferencesPage to avoid the root cause during instantiation. Fixes: musescore#33841
ab146d9 to
b9cafb6
Compare
Related to: #33841
When a preference page fails to instantiate (e.g. due to a null-parent binding on the first layout pass), it is skipped and never stored in
prv.pagesObjects. The apply loop inPreferencesDialogiterated allpages from
availablePages()without guarding against missing entries, soobj.apply()threw a TypeError onundefined, corrupting theokaccumulator and preventingroot.hide(). Changes were silently discarded with no UI feedback.PreferencesDialog.qml: guardobjbefore callingapply().PreferencesPage.qml: null-safeparentbinding to avoid the TypeError during instantiation.Reproduced on macOS 15 (arm64), MuseScore 4.7.3 and 5.0.0 developer builds with
-DMUE_BUILD_MACOS_INTEGRATION=OFF.