Fix(ui): Avoid ERROR macro conflict in iconcodes#48
Conversation
📝 WalkthroughWalkthroughThis PR renames the 🚥 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 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: 2
🤖 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 `@framework/ui/view/iconcodes.h`:
- Around line 34-36: The preprocessor guard for ERROR_ICON is unnecessary
because ERROR_ICON is not a platform macro; remove the `#ifdef` ERROR_ICON /
`#undef` ERROR_ICON / `#endif` block and instead either leave no undef for
ERROR_ICON or, if the intent was to avoid colliding with platform ERROR, restore
the original `#undef` ERROR (not ERROR_ICON) before defining the enum entries;
update any enum rename references (e.g., ERROR_ICON vs ERROR) so the enum uses
the intended identifier (such as ERROR_ICON) and ensure WARNING, INFO, QUESTION
handling remains unchanged.
- Line 343: The QML enum named in code is now ERROR_ICON (not ERROR), so update
all places returning or referencing IconCode.ERROR — specifically in the
StandardDialogPanel.qml function standardIcon(type) (and any other QML/JS
callers) change IconCode.ERROR to IconCode.ERROR_ICON; search for IconCode.ERROR
usages and replace them with IconCode.ERROR_ICON to prevent QML enum
lookup/compile failures.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 0d51e0a6-f903-4d82-9d0e-5e519d16b9b4
📒 Files selected for processing (1)
framework/ui/view/iconcodes.h
| #ifdef ERROR_ICON | ||
| #undef ERROR_ICON | ||
| #endif |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | 💤 Low value
The ERROR_ICON guard is unnecessary.
Unlike ERROR, WARNING, INFO, and QUESTION, the name ERROR_ICON is not a macro defined by platform headers (e.g., Windows). This guard serves no protective purpose and can be safely removed. Alternatively, if downstream headers still require ERROR to be cleared, the original #undef ERROR should be retained alongside the enum rename.
🧹 Suggested removal
-#ifdef ERROR_ICON
-#undef ERROR_ICON
-#endif📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #ifdef ERROR_ICON | |
| #undef ERROR_ICON | |
| #endif |
🤖 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 `@framework/ui/view/iconcodes.h` around lines 34 - 36, The preprocessor guard
for ERROR_ICON is unnecessary because ERROR_ICON is not a platform macro; remove
the `#ifdef` ERROR_ICON / `#undef` ERROR_ICON / `#endif` block and instead either
leave no undef for ERROR_ICON or, if the intent was to avoid colliding with
platform ERROR, restore the original `#undef` ERROR (not ERROR_ICON) before
defining the enum entries; update any enum rename references (e.g., ERROR_ICON
vs ERROR) so the enum uses the intended identifier (such as ERROR_ICON) and
ensure WARNING, INFO, QUESTION handling remains unchanged.
| WARNING = 0xF3CE, | ||
| INFO = 0xF3CF, | ||
| ERROR = 0xF3D0, | ||
| ERROR_ICON = 0xF3D0, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Search for usages of the old Code::ERROR enum value that need updating.
# Search for explicit Code::ERROR or IconCode::ERROR references
rg -n --type=cpp --type=qml -e 'Code::ERROR\b' -e 'IconCode::ERROR\b' -g '!iconcodes.h'
# Also check for QML usages
rg -n -e 'IconCode\.ERROR\b' --type-add 'qml:*.qml' --type=qmlRepository: musescore/muse_framework
Length of output: 182
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== iconcodes.h enum definitions around ERROR ==="
rg -n --type=cpp "enum class Code|ERROR_ICON|\\bERROR\\b" framework/ui/view/iconcodes.h
echo "--- snippet near ERROR_ICON ---"
python3 - <<'PY'
import re
path="framework/ui/view/iconcodes.h"
start=300; end=420
with open(path,'r',encoding='utf-8',errors='ignore') as f:
lines=f.readlines()
for i in range(start-1,end):
if 1<=i+1<=len(lines):
print(f"{i+1}: {lines[i].rstrip()}")
PY
echo
echo "=== Remaining usages of old names (excluding iconcodes.h) ==="
rg -n --type=cpp --type=qml -e 'Code::ERROR\b' -e 'IconCode::ERROR\b' -g '!iconcodes.h' .
rg -n -e 'IconCode\.ERROR\b' --type-add 'qml:*.qml' --type=qml .
echo
echo "=== Usages of new names (ERROR_ICON) ==="
rg -n --type=cpp --type=qml -e 'ERROR_ICON\b' -g '!iconcodes.h' .
rg -n -e 'IconCode\.ERROR_ICON\b' --type-add 'qml:*.qml' --type=qml . || true
echo
echo "=== Specific QML mapping location found earlier ==="
rg -n "case \"ERROR\"" -S framework/interactive/qml/Muse/Interactive/StandardDialogPanel.qml
sed -n '60,105p' framework/interactive/qml/Muse/Interactive/StandardDialogPanel.qmlRepository: musescore/muse_framework
Length of output: 3236
🏁 Script executed:
#!/bin/bash
set -u
echo "=== iconcodes.h: presence of ERROR_ICON ==="
rg -n --type=cpp "ERROR_ICON\\b" framework/ui/view/iconcodes.h
echo
echo "=== QML: remaining IconCode.ERROR references ==="
rg -n --type=qml "IconCode\\.ERROR\\b" . || true
echo
echo "=== QML: case \"ERROR\" mapping ==="
rg -n 'case[[:space:]]+"ERROR"' -S --type=qml framework/interactive/qml/Muse/Interactive/StandardDialogPanel.qml || true
sed -n '70,100p' framework/interactive/qml/Muse/Interactive/StandardDialogPanel.qml
echo
echo "=== Usages of ERROR_ICON ==="
rg -n --type=cpp --type=qml "\\bERROR_ICON\\b" . -g '!iconcodes.h' || true
rg -n --type=qml "IconCode\\.ERROR_ICON\\b" . || trueRepository: musescore/muse_framework
Length of output: 1306
🏁 Script executed:
#!/bin/bash
set -u
echo "=== iconcodes.h: occurrences of ERROR not followed by _ (to catch potential aliases) ==="
rg -n --type=cpp -S "ERROR(?!_)" framework/ui/view/iconcodes.h || true
echo
echo "=== iconcodes.h: lines mentioning ERROR_ICON specifically ==="
rg -n --type=cpp "ERROR_ICON" framework/ui/view/iconcodes.h
echo
echo "=== iconcodes.h: top-of-file preprocessor context around ERROR_ICON ==="
sed -n '1,120p' framework/ui/view/iconcodes.h
echo
echo "=== iconcodes.h: QML exposure (Q_ENUM / Q_NAMESPACE / etc) near the enum ==="
# show a wider window around the enum declaration and any QML macros
sed -n '40,120p' framework/ui/view/iconcodes.h
sed -n '320,380p' framework/ui/view/iconcodes.h
echo
echo "=== sanity: any 'ERROR' enum value entries in iconcodes.h (comma form) ==="
rg -n --type=cpp "ERROR\\s*=" framework/ui/view/iconcodes.h || true
rg -n --type=cpp "ERROR\\s*," framework/ui/view/iconcodes.h || trueRepository: musescore/muse_framework
Length of output: 7021
Breaking API change: remaining IconCode.ERROR usage needs updating
framework/ui/view/iconcodes.h defines ERROR_ICON (no ERROR enum value), but framework/interactive/qml/Muse/Interactive/StandardDialogPanel.qml:84 still returns IconCode.ERROR in standardIcon(type) when type === "ERROR"—update it to IconCode.ERROR_ICON to avoid QML enum lookup/compile failures.
🤖 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 `@framework/ui/view/iconcodes.h` at line 343, The QML enum named in code is now
ERROR_ICON (not ERROR), so update all places returning or referencing
IconCode.ERROR — specifically in the StandardDialogPanel.qml function
standardIcon(type) (and any other QML/JS callers) change IconCode.ERROR to
IconCode.ERROR_ICON; search for IconCode.ERROR usages and replace them with
IconCode.ERROR_ICON to prevent QML enum lookup/compile failures.
|
Could you please provide the compiler error log? We know that Windows headers contain Isn't that enough? This enumerator is used in MuseScoreStudio and Audacity. Therefore, if we change it, we need to change the code in both projects... It also needs to look consistent, as the rabbit pointed out... |
Rename
ERRORenum value toERROR_ICONand update the related #undef guard to prevent macro name collisions on some platforms or third-party headers.