Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in Toolkit::RedoLayout. Fixes #3900 #3901

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/vrv/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ class Object : public BoundingBox {
*/
Object *DetachChild(int idx);

/**
* Replace an object with a copy of the other.
* They must be of the same class.
*/
void ReplaceWithCopyOf(Object *object);

/**
* Return true if the object has the child Object as descendant (reference of direct).
* Processes in depth-first.
Expand Down
2 changes: 1 addition & 1 deletion src/calcalignmentpitchposfunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ FunctorCode CalcAlignmentPitchPosFunctor::VisitStaffDef(StaffDef *staffDef)
m_octDefaultForStaffN[staffDef->GetN()] = staffDef->GetOctDefault();
}

return FUNCTOR_CONTINUE;
return FUNCTOR_SIBLINGS;
}

} // namespace vrv
8 changes: 8 additions & 0 deletions src/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ Object *Object::DetachChild(int idx)
return child;
}

void Object::ReplaceWithCopyOf(Object *object)
{
Object *parent = this->GetParent();
*this = *object;
this->CloneReset();
this->SetParent(parent);
}

bool Object::HasDescendant(const Object *child, int deepness) const
{
ArrayOfObjects::const_iterator iter;
Expand Down
10 changes: 5 additions & 5 deletions src/scoredef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,21 @@ void ScoreDef::ResetFromDrawingValues()
assert(staffDef);

Clef *clef = vrv_cast<Clef *>(staffDef->FindDescendantByType(CLEF));
if (clef) *clef = *staffDef->GetCurrentClef();
if (clef) clef->ReplaceWithCopyOf(staffDef->GetCurrentClef());

KeySig *keySig = vrv_cast<KeySig *>(staffDef->FindDescendantByType(KEYSIG));
if (keySig) *keySig = *staffDef->GetCurrentKeySig();
if (keySig) keySig->ReplaceWithCopyOf(staffDef->GetCurrentKeySig());

Mensur *mensur = vrv_cast<Mensur *>(staffDef->FindDescendantByType(MENSUR));
if (mensur) *mensur = *staffDef->GetCurrentMensur();
if (mensur) mensur->ReplaceWithCopyOf(staffDef->GetCurrentMensur());

MeterSigGrp *meterSigGrp = vrv_cast<MeterSigGrp *>(staffDef->FindDescendantByType(METERSIGGRP));
MeterSig *meterSig = vrv_cast<MeterSig *>(staffDef->FindDescendantByType(METERSIG));
if (meterSigGrp) {
*meterSigGrp = *staffDef->GetCurrentMeterSigGrp();
meterSigGrp->ReplaceWithCopyOf(staffDef->GetCurrentMeterSigGrp());
}
else if (meterSig) {
*meterSig = *staffDef->GetCurrentMeterSig();
meterSig->ReplaceWithCopyOf(staffDef->GetCurrentMeterSig());
}
}
}
Expand Down
Loading