@@ -4749,11 +4749,29 @@ MeasureBase* Score::insertMeasure(ElementType type, MeasureBase* beforeMeasure,
47494749MeasureBase* Score::insertBox (ElementType type, MeasureBase* beforeMeasure, const InsertMeasureOptions& options)
47504750{
47514751 const bool isFrame = type == ElementType::FBOX || type == ElementType::HBOX || type == ElementType::TBOX || type == ElementType::VBOX ;
4752+ if (!isFrame) {
4753+ return nullptr ;
4754+ }
4755+
4756+ return this ->insertBox (toMeasureBase (Factory::createItem (type, dummy ())), beforeMeasure, options);
4757+ }
4758+
4759+ MeasureBase* Score::insertBox (MeasureBase* box, MeasureBase* beforeMeasure, const InsertMeasureOptions& options)
4760+ {
4761+ IF_ASSERT_FAILED (box) {
4762+ return nullptr ;
4763+ }
47524764
4765+ ElementType type = box->type ();
4766+ const bool isFrame = type == ElementType::FBOX || type == ElementType::HBOX || type == ElementType::TBOX || type == ElementType::VBOX ;
47534767 if (!isFrame) {
47544768 return nullptr ;
47554769 }
47564770
4771+ if (box->score () != this ) {
4772+ box->setScore (this );
4773+ }
4774+
47574775 Fraction tick;
47584776 bool isTitleFrame = type == ElementType::VBOX && beforeMeasure && beforeMeasure == beforeMeasure->score ()->first ();
47594777 if (beforeMeasure) {
@@ -4777,27 +4795,26 @@ MeasureBase* Score::insertBox(ElementType type, MeasureBase* beforeMeasure, cons
47774795 tick = last () ? last ()->endTick () : Fraction (0 , 1 );
47784796 }
47794797
4780- MeasureBase* newMeasureBase = toMeasureBase (Factory::createItem (type, dummy ()));
4781- newMeasureBase->setTick (tick);
4782- newMeasureBase->setNext (beforeMeasure);
4783- newMeasureBase->setPrev (beforeMeasure ? beforeMeasure->prev () : last ());
4784- newMeasureBase->setSizeIsSpatiumDependent (!isTitleFrame);
4798+ box->setTick (tick);
4799+ box->setNext (beforeMeasure);
4800+ box->setPrev (beforeMeasure ? beforeMeasure->prev () : last ());
4801+ box->setSizeIsSpatiumDependent (!isTitleFrame);
47854802
47864803 if (type == ElementType::FBOX ) {
4787- toFBox (newMeasureBase )->init ();
4804+ toFBox (box )->init ();
47884805 }
47894806
4790- undo (new InsertMeasures (newMeasureBase, newMeasureBase ));
4807+ undo (new InsertMeasures (box, box ));
47914808
47924809 if (options.needDeselectAll ) {
47934810 deselectAll ();
47944811 }
47954812
47964813 if (options.cloneBoxToAllParts ) {
4797- newMeasureBase ->manageExclusionFromParts (/* exclude =*/ false );
4814+ box ->manageExclusionFromParts (/* exclude =*/ false );
47984815 }
47994816
4800- return newMeasureBase ;
4817+ return box ;
48014818}
48024819
48034820void Score::restoreInitialKeySigAndTimeSig ()
0 commit comments