Skip to content

Commit

Permalink
fix #278430: fix layout of chord symbols without chord or rest
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 committed Nov 19, 2018
1 parent db594ae commit 3653f4b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
9 changes: 8 additions & 1 deletion libmscore/layout.cpp
Expand Up @@ -3448,8 +3448,15 @@ System* Score::collectSystem(LayoutContext& lc)
for (Element* e : s->annotations()) {
if (e->isStaffText() || e->isSystemText() || e->isInstrumentChange())
e->layout();
if (e->isHarmony())
if (e->isHarmony()) {
Harmony* h = toHarmony(e);
// Layout of harmony seems to be bound currently
// to ChordRest (see ChordRest::shape). But harmony
// can exist without chord or rest too.
if (h->isLayoutInvalid())
h->layout();
toHarmony(e)->autoplaceSegmentElement(styleP(Sid::minHarmonyDistance));
}
}
}

Expand Down
26 changes: 20 additions & 6 deletions libmscore/textbase.cpp
Expand Up @@ -1879,10 +1879,17 @@ QString TextBase::plainText() const
{
QString s;

if (layoutInvalid)
((Text*)(this))->createLayout(); // ugh!
const TextBase* text = this;
std::unique_ptr<TextBase> tmpText;
if (layoutInvalid) {
// Create temporary text object to avoid side effects
// of createLayout() call.
tmpText.reset(toTextBase(this->clone()));
tmpText->createLayout();
text = tmpText.get();
}

for (const TextBlock& block : _layout) {
for (const TextBlock& block : text->_layout) {
for (const TextFragment& f : block.fragments())
s += f.text;
if (block.eol())
Expand All @@ -1897,9 +1904,16 @@ QString TextBase::plainText() const

QString TextBase::xmlText() const
{
if (textInvalid)
((Text*)(this))->genText(); // ugh!
return _text;
const TextBase* text = this;
std::unique_ptr<TextBase> tmpText;
if (textInvalid) {
// Create temporary text object to avoid side effects
// of genText() call.
tmpText.reset(toTextBase(this->clone()));
tmpText->genText();
text = tmpText.get();
}
return text->_text;
}

//---------------------------------------------------------
Expand Down
12 changes: 10 additions & 2 deletions mtest/libmscore/layout_elements/layout_elements.mscx
Expand Up @@ -12,7 +12,7 @@
<lyricsMinBottomDistance>6</lyricsMinBottomDistance>
<frameSystemDistance>13</frameSystemDistance>
<measureSpacing>1.14</measureSpacing>
<voltaPosAbove>0</voltaPosAbove>
<voltaPosAbove x="0" y="0"/>
<Spatium>1.564</Spatium>
</Style>
<showInvisible>1</showInvisible>
Expand Down Expand Up @@ -827,7 +827,6 @@
<voice>
<Harmony>
<root>14</root>
<name>hord</name>
</Harmony>
<Chord>
<durationType>whole</durationType>
Expand All @@ -844,6 +843,15 @@
<tpc>18</tpc>
</Note>
</Chord>
<location>
<fractions>-5/8</fractions>
</location>
<Harmony>
<root>16</root>
</Harmony>
<location>
<fractions>5/8</fractions>
</location>
<Rest>
<durationType>half</durationType>
</Rest>
Expand Down

0 comments on commit 3653f4b

Please sign in to comment.