diff --git a/include/vrv/object.h b/include/vrv/object.h index f5c2590419..6ed92a8265 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -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. diff --git a/src/calcalignmentpitchposfunctor.cpp b/src/calcalignmentpitchposfunctor.cpp index dabdc80d3e..1887e8cfe9 100644 --- a/src/calcalignmentpitchposfunctor.cpp +++ b/src/calcalignmentpitchposfunctor.cpp @@ -357,7 +357,7 @@ FunctorCode CalcAlignmentPitchPosFunctor::VisitStaffDef(StaffDef *staffDef) m_octDefaultForStaffN[staffDef->GetN()] = staffDef->GetOctDefault(); } - return FUNCTOR_CONTINUE; + return FUNCTOR_SIBLINGS; } } // namespace vrv diff --git a/src/object.cpp b/src/object.cpp index cc9bfeb9aa..52cfdaa7c4 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -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; diff --git a/src/scoredef.cpp b/src/scoredef.cpp index 172f1d5a02..5185a08acb 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -484,21 +484,21 @@ void ScoreDef::ResetFromDrawingValues() assert(staffDef); Clef *clef = vrv_cast(staffDef->FindDescendantByType(CLEF)); - if (clef) *clef = *staffDef->GetCurrentClef(); + if (clef) clef->ReplaceWithCopyOf(staffDef->GetCurrentClef()); KeySig *keySig = vrv_cast(staffDef->FindDescendantByType(KEYSIG)); - if (keySig) *keySig = *staffDef->GetCurrentKeySig(); + if (keySig) keySig->ReplaceWithCopyOf(staffDef->GetCurrentKeySig()); Mensur *mensur = vrv_cast(staffDef->FindDescendantByType(MENSUR)); - if (mensur) *mensur = *staffDef->GetCurrentMensur(); + if (mensur) mensur->ReplaceWithCopyOf(staffDef->GetCurrentMensur()); MeterSigGrp *meterSigGrp = vrv_cast(staffDef->FindDescendantByType(METERSIGGRP)); MeterSig *meterSig = vrv_cast(staffDef->FindDescendantByType(METERSIG)); if (meterSigGrp) { - *meterSigGrp = *staffDef->GetCurrentMeterSigGrp(); + meterSigGrp->ReplaceWithCopyOf(staffDef->GetCurrentMeterSigGrp()); } else if (meterSig) { - *meterSig = *staffDef->GetCurrentMeterSig(); + meterSig->ReplaceWithCopyOf(staffDef->GetCurrentMeterSig()); } } }