Skip to content
Permalink
Browse files

Merge pull request #5293 from jthistle/293707-undo-no-restore-deleted…

…-frame

fix #293707: undo doesn't restore deleted frame immediately
  • Loading branch information...
anatoly-os committed Sep 4, 2019
2 parents c490c0e + 3f40a56 commit 60f463f7fb2207dceb5fc703311c8d5dba04aadc
@@ -1391,6 +1391,7 @@ void Score::addElement(Element* element)
|| et == ElementType::FBOX
) {
measures()->add(toMeasureBase(element));
setLayout(element->tick());
return;
}

@@ -2096,7 +2097,7 @@ bool Score::appendScore(Score* score, bool addPageBreak, bool addSectionBreak)
else if (!last()->lineBreak() && !last()->pageBreak()) {
last()->undoSetBreak(true, LayoutBreak::Type::LINE);
}

if (addSectionBreak && !last()->sectionBreak())
last()->undoSetBreak(true, LayoutBreak::Type::SECTION);

@@ -2144,7 +2145,7 @@ bool Score::appendMeasuresFromScore(Score* score, const Fraction& startTick, con
pmb->setNext(nmb);
pmb = nmb;
}

Measure* firstAppendedMeasure = tick2measure(tickOfAppend);

// if the appended score has less staves,
@@ -2170,7 +2171,7 @@ bool Score::appendMeasuresFromScore(Score* score, const Fraction& startTick, con
int trackIdx = staff2track(staffIdx); // idx of irst track on the staff
Staff* staff = this->staff(staffIdx);
Staff* ostaff = score->staff(staffIdx);

// check if key signature needs to be changed
if (ostaff->key(otick) != staff->key(ctick)) {
Segment* ns = firstAppendedMeasure->undoGetSegment(SegmentType::KeySig, ctick);
@@ -2190,7 +2191,7 @@ bool Score::appendMeasuresFromScore(Score* score, const Fraction& startTick, con
if (ns)
ns->remove(ns->element(trackIdx));
}

// check if time signature needs to be changed
TimeSig* ots = ostaff->timeSig(otick), * cts = staff->timeSig(ctick);
TimeSig* pts = staff->timeSig(ctick - Fraction::fromTicks(1));
@@ -2235,7 +2236,7 @@ bool Score::appendMeasuresFromScore(Score* score, const Fraction& startTick, con
auto lb = ospans.lower_bound(startTick.ticks()), ub = ospans.upper_bound(endTick.ticks());
for (auto sp = lb; sp != ub; sp++) {
Spanner* spanner = sp->second;

if (spanner->tick2() > endTick) continue; // map is by tick() so this can still happen in theory...

Spanner* ns = toSpanner(spanner->clone());
@@ -204,6 +204,7 @@ subdirs (
libmscore/barline
libmscore/beam
libmscore/breath
libmscore/box
libmscore/chordsymbol
libmscore/clef
libmscore/clef_courtesy
@@ -0,0 +1,16 @@
#=============================================================================
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2019 Werner Schweer
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation and appearing in
# the file LICENSE.GPL
#=============================================================================

set(TARGET tst_box)

include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc)

@@ -0,0 +1,79 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2019 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================

#include <QtTest/QtTest>
#include "mtest/testutils.h"
#include "libmscore/score.h"
#include "libmscore/system.h"
#include "libmscore/undo.h"
#include "libmscore/box.h"

#define DIR QString("libmscore/box/")

using namespace Ms;

//---------------------------------------------------------
// TestBox
//---------------------------------------------------------

class TestBox : public QObject, public MTest
{
Q_OBJECT

private slots:
void initTestCase();
void undoRemoveVBox();
};

//---------------------------------------------------------
// initTestCase
//---------------------------------------------------------

void TestBox::initTestCase()
{
initMTest();
}

//---------------------------------------------------------
// undoRemoveVBox
/// read a file with a vbox. Delete it, and undo. Check that the VBox still exists.
//---------------------------------------------------------

void TestBox::undoRemoveVBox()
{
QString readFile(DIR + "undoRemoveVBox.mscx");
QString writeFile1("undoRemoveVBox1-test.mscx");
QString reference1(DIR + "undoRemoveVBox1-ref.mscx");
QString writeFile2("undoRemoveVBox2-test.mscx");
QString reference2(DIR + "undoRemoveVBox2-ref.mscx");

MasterScore* score = readScore(readFile);
score->doLayout();

System* s = score->systems()[0];
VBox* box = toVBox(s->measure(0));

score->startCmd();
score->select(box);
score->cmdDeleteSelection();
score->endCmd();
QVERIFY(saveCompareScore(score, writeFile1, reference1));

// undo
score->undoStack()->undo(nullptr);
QVERIFY(saveCompareScore(score, writeFile2, reference2));

delete score;
}

QTEST_MAIN(TestBox)
#include "tst_box.moc"
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.01">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer">Composer</metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle">Title</metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Piano</trackName>
<Instrument>
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<Text>
<style>Title</style>
<text>VBox</text>
</Text>
</VBox>
<!-- Measure 1 -->
<Measure>
<voice>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</voice>
</Measure>
<!-- Measure 2 -->
<Measure>
<voice>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</voice>
</Measure>
<!-- Measure 3 -->
<Measure>
<voice>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</voice>
</Measure>
<!-- Measure 4 -->
<Measure>
<voice>
<Rest>
<durationType>measure</durationType>
<duration>4/4</duration>
</Rest>
</voice>
</Measure>
</Staff>
</Score>
</museScore>

0 comments on commit 60f463f

Please sign in to comment.
You can’t perform that action at this time.