Skip to content

Fix C++20 compiler warnings#44

Merged
igorkorsukov merged 2 commits into
musescore:mainfrom
cbjeukendrup:c++20-warning-fixes
May 20, 2026
Merged

Fix C++20 compiler warnings#44
igorkorsukov merged 2 commits into
musescore:mainfrom
cbjeukendrup:c++20-warning-fixes

Conversation

@cbjeukendrup
Copy link
Copy Markdown
Contributor

(without relying on C++20 features)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Review Change Stack

Warning

Rate limit exceeded

@cbjeukendrup has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 35 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e2ba2f2f-8ad7-45ab-95cd-2008d092178a

📥 Commits

Reviewing files that changed from the base of the PR and between 916f480 and dfeda3e.

📒 Files selected for processing (13)
  • framework/draw/bufferedpaintprovider.cpp
  • framework/draw/bufferedpaintprovider.h
  • framework/draw/internal/qpainterprovider.cpp
  • framework/draw/internal/qpainterprovider.h
  • framework/draw/ipaintprovider.h
  • framework/draw/painter.cpp
  • framework/draw/painter.h
  • framework/draw/types/drawdata.h
  • framework/draw/types/drawtypes.h
  • framework/draw/utils/drawdatacomp.cpp
  • framework/draw/utils/drawdatajson.cpp
  • framework/draw/utils/drawdatapaint.cpp
  • framework/testflow/internal/draw/abpaintprovider.cpp
📝 Walkthrough

Walkthrough

This PR refactors the text drawing API throughout the framework to use explicit Alignment and TextFlags parameters instead of packed integer flags, enabling type-safe and self-documenting text layout specifications. The DrawText struct fields are updated accordingly, and all paint provider implementations—including IPaintProvider, Painter, BufferedPaintProvider, and QPainterProvider—are updated to use the new signatures. Supporting utilities for JSON serialization, equality comparison, and rendering are adapted to work with the new fields. Concurrently, the PR modernizes several headers to use #pragma once instead of traditional include guards and improves lambda capture specificity in delayed selection callbacks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description is minimal but aligns with the template and PR objectives. However, it lacks required sections like issue reference, motivation details, and CLA/checklist confirmation. Add GitHub issue reference (Resolves: #NNNNN), expand motivation/description of the warnings fixed, and include the required checklist from the template for clarity.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main focus of the changeset: addressing C++20 compiler warnings through code updates across multiple drawing and audio components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/draw/painter.h`:
- Around line 22-23: Remove the extra leading blank line before the `#pragma` once
directive in framework/draw/painter.h so the file begins immediately with
"`#pragma` once"; this will satisfy the codestyle formatter and allow the CI
codestyle job to pass.

In `@framework/draw/utils/drawdatajson.cpp`:
- Around line 338-339: The deserializer currently assigns text.alignment and
text.textFlags only from obj["alignment"] and obj["textFlags"], losing legacy
values stored under a single "flags" field; update the DrawText deserialization
to detect a legacy obj.contains("flags") and, when present and
alignment/textFlags keys are missing, read int flags = obj["flags"].toInt() and
decompose that value into the appropriate Alignment and TextFlags bits before
assigning text.alignment and text.textFlags (use the same bit masks/enum mapping
used elsewhere for these enums to ensure compatibility).
🪄 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: 054f890f-696f-4ecc-8825-18e38464ca40

📥 Commits

Reviewing files that changed from the base of the PR and between 6048dd6 and 916f480.

📒 Files selected for processing (15)
  • framework/audio/engine/internal/fx/reverb/circularsamplebuffer.h
  • framework/draw/bufferedpaintprovider.cpp
  • framework/draw/bufferedpaintprovider.h
  • framework/draw/internal/qpainterprovider.cpp
  • framework/draw/internal/qpainterprovider.h
  • framework/draw/ipaintprovider.h
  • framework/draw/painter.cpp
  • framework/draw/painter.h
  • framework/draw/types/drawdata.h
  • framework/draw/types/drawtypes.h
  • framework/draw/utils/drawdatacomp.cpp
  • framework/draw/utils/drawdatajson.cpp
  • framework/draw/utils/drawdatapaint.cpp
  • framework/testflow/internal/draw/abpaintprovider.cpp
  • framework/uicomponents/qml/Muse/UiComponents/abstracttableviewmodel.cpp

Comment thread framework/draw/painter.h Outdated
Comment on lines +338 to +339
text.alignment = static_cast<Alignment>(obj["alignment"].toInt());
text.textFlags = static_cast<TextFlags>(obj["textFlags"].toInt());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add legacy flags fallback in DrawText deserialization.

Line 338-339 only reads alignment and textFlags; older JSON containing only flags will silently deserialize with zeroed layout flags.

💡 Proposed compatibility fix
-    text.alignment = static_cast<Alignment>(obj["alignment"].toInt());
-    text.textFlags = static_cast<TextFlags>(obj["textFlags"].toInt());
+    const int legacyFlags = obj.value("flags").toInt();
+    text.alignment = obj.contains("alignment")
+            ? static_cast<Alignment>(obj.value("alignment").toInt())
+            : static_cast<Alignment>(legacyFlags);
+    text.textFlags = obj.contains("textFlags")
+            ? static_cast<TextFlags>(obj.value("textFlags").toInt())
+            : static_cast<TextFlags>(legacyFlags);
📝 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.

Suggested change
text.alignment = static_cast<Alignment>(obj["alignment"].toInt());
text.textFlags = static_cast<TextFlags>(obj["textFlags"].toInt());
const int legacyFlags = obj.value("flags").toInt();
text.alignment = obj.contains("alignment")
? static_cast<Alignment>(obj.value("alignment").toInt())
: static_cast<Alignment>(legacyFlags);
text.textFlags = obj.contains("textFlags")
? static_cast<TextFlags>(obj.value("textFlags").toInt())
: static_cast<TextFlags>(legacyFlags);
🤖 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/draw/utils/drawdatajson.cpp` around lines 338 - 339, The
deserializer currently assigns text.alignment and text.textFlags only from
obj["alignment"] and obj["textFlags"], losing legacy values stored under a
single "flags" field; update the DrawText deserialization to detect a legacy
obj.contains("flags") and, when present and alignment/textFlags keys are
missing, read int flags = obj["flags"].toInt() and decompose that value into the
appropriate Alignment and TextFlags bits before assigning text.alignment and
text.textFlags (use the same bit masks/enum mapping used elsewhere for these
enums to ensure compatibility).


void drawText(const PointF& point, const String& text) override;
void drawText(const RectF& rect, int flags, const String& text) override;
void drawText(const RectF& rect, Alignment alignment, TextFlags textFlags, const String& text) override;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to add a new method here...
and then delete the old one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... but I got the corresponding MSS PR already ready: musescore/MuseScore#33504

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try to merge them quickly!

But it's better to go with compatibility, especially in simple cases like these. Add something new, mark something old as deprecated, and remove it after syncing.

@cbjeukendrup cbjeukendrup force-pushed the c++20-warning-fixes branch from 916f480 to dfeda3e Compare May 20, 2026 13:02
@igorkorsukov igorkorsukov merged commit 0fc3b4e into musescore:main May 20, 2026
3 checks passed
@cbjeukendrup cbjeukendrup deleted the c++20-warning-fixes branch May 20, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants