From dbf6737fc5b8be68b5a29d6047f82ab2bf529e18 Mon Sep 17 00:00:00 2001 From: Joachim Schmitz Date: Thu, 7 Nov 2024 19:08:21 +0100 Subject: [PATCH] Fix MSVC compiler warnings reg. 'argument': conversion from 'size_t' to 'int', possible loss of data (C4267) --- src/engraving/dom/segment.h | 6 +++--- src/engraving/rendering/score/chordlayout.cpp | 10 +++++----- src/engraving/rendering/score/measurelayout.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/engraving/dom/segment.h b/src/engraving/dom/segment.h index d04c7a52a52f9..9619c0d6afe0f 100644 --- a/src/engraving/dom/segment.h +++ b/src/engraving/dom/segment.h @@ -297,9 +297,9 @@ class Segment final : public EngravingItem bool hasAccidentals() const; - EngravingItem* preAppendedItem(int track) { return m_preAppendedItems[track]; } - void preAppend(EngravingItem* item, int track) { m_preAppendedItems[track] = item; } - void clearPreAppended(int track) { m_preAppendedItems[track] = nullptr; } + EngravingItem* preAppendedItem(track_idx_t track) { return m_preAppendedItems[track]; } + void preAppend(EngravingItem* item, track_idx_t track) { m_preAppendedItems[track] = item; } + void clearPreAppended(track_idx_t track) { m_preAppendedItems[track] = nullptr; } void addPreAppendedToShape(); bool goesBefore(const Segment* nextSegment) const; diff --git a/src/engraving/rendering/score/chordlayout.cpp b/src/engraving/rendering/score/chordlayout.cpp index 1fcd916398278..cb6325a3f48bc 100644 --- a/src/engraving/rendering/score/chordlayout.cpp +++ b/src/engraving/rendering/score/chordlayout.cpp @@ -2675,13 +2675,13 @@ void ChordLayout::appendGraceNotes(Chord* chord) if (!gnb.empty()) { // If this segment already contains grace notes in the same voice (could happen if a // previous chord has appended grace-notes-after here) put them in the same vector. - EngravingItem* item = segment->preAppendedItem(static_cast(track)); + EngravingItem* item = segment->preAppendedItem(track); if (item && item->isGraceNotesGroup()) { GraceNotesGroup* gng = toGraceNotesGroup(item); gng->insert(gng->end(), gnb.begin(), gnb.end()); } else { gnb.setAppendedSegment(segment); - segment->preAppend(&gnb, static_cast(track)); + segment->preAppend(&gnb, track); } } @@ -2695,7 +2695,7 @@ void ChordLayout::appendGraceNotes(Chord* chord) } if (followingSeg) { gna.setAppendedSegment(followingSeg); - followingSeg->preAppend(&gna, static_cast(track)); + followingSeg->preAppend(&gna, track); } } } @@ -2705,8 +2705,8 @@ void ChordLayout::appendGraceNotes(Chord* chord) * is needed and must be called AFTER horizontal spacing is calculated. */ void ChordLayout::repositionGraceNotesAfter(Segment* segment, size_t tracks) { - for (size_t track = 0; track < tracks; track++) { - EngravingItem* item = segment->preAppendedItem(static_cast(track)); + for (track_idx_t track = 0; track < tracks; track++) { + EngravingItem* item = segment->preAppendedItem(track); if (!item || !item->isGraceNotesGroup()) { continue; } diff --git a/src/engraving/rendering/score/measurelayout.cpp b/src/engraving/rendering/score/measurelayout.cpp index 0f0aab90fb73c..1dc80d98cc040 100644 --- a/src/engraving/rendering/score/measurelayout.cpp +++ b/src/engraving/rendering/score/measurelayout.cpp @@ -1005,7 +1005,7 @@ void MeasureLayout::updateGraceNotes(Measure* measure, LayoutContext& ctx) { // Clean everything for (Segment& s : measure->segments()) { - for (unsigned track = 0; track < ctx.dom().ntracks(); ++track) { + for (track_idx_t track = 0; track < ctx.dom().ntracks(); ++track) { EngravingItem* e = s.preAppendedItem(track); if (e && e->isGraceNotesGroup()) { s.clearPreAppended(track); @@ -1035,7 +1035,7 @@ void MeasureLayout::updateGraceNotes(Measure* measure, LayoutContext& ctx) // Layout grace note groups for (Segment& s : measure->segments()) { - for (unsigned track = 0; track < ctx.dom().ntracks(); ++track) { + for (track_idx_t track = 0; track < ctx.dom().ntracks(); ++track) { EngravingItem* e = s.preAppendedItem(track); if (e && e->isGraceNotesGroup()) { GraceNotesGroup* gng = toGraceNotesGroup(e);