Skip to content

Commit

Permalink
Remove const_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Dec 9, 2024
1 parent 226fa15 commit 1e3fc62
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/midifunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,11 @@ FunctorCode GenerateMIDIFunctor::VisitPedal(const Pedal *pedal)
if (!m_controlEvents || !this->GetFilters()) return FUNCTOR_CONTINUE;

// Check if the pedal applies to the staff filtered
Pedal *nonConstPedal = const_cast<Pedal *>(pedal);
Measure *measure = vrv_cast<Measure *>(nonConstPedal->GetFirstAncestor(MEASURE));
const Measure *measure = vrv_cast<const Measure *>(pedal->GetFirstAncestor(MEASURE));
assert(measure);
std::vector<Staff *> staffList = nonConstPedal->GetTstampStaves(measure, nonConstPedal);
std::vector<const Staff *> staffList = pedal->GetTstampStaves(measure, pedal);
bool applies = false;
for (Staff *staff : staffList) {
for (const Staff *staff : staffList) {
applies = (applies || this->GetFilters()->Apply(staff));
}
if (!applies) return FUNCTOR_CONTINUE;
Expand Down

0 comments on commit 1e3fc62

Please sign in to comment.