Skip to content

Commit

Permalink
Fix GH#18158: Do not export invisible text lines
Browse files Browse the repository at this point in the history
Backport of musescore#20225
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Dec 5, 2023
1 parent f10cb54 commit 7a88317
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 16 additions & 6 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4592,6 +4592,10 @@ void ExportMusicXml::hairpin(Hairpin const* const hp, int staff, const Fraction&
const auto isLineType = hp->isLineType();
int n;
if (isLineType) {
if (!hp->lineVisible() && ((hp->beginText().isEmpty() && hp->tick() == tick)
|| (hp->endText().isEmpty() && hp->tick() != tick)))
return;

n = findDashes(hp);
if (n >= 0)
dashes[n] = nullptr;
Expand Down Expand Up @@ -4822,6 +4826,10 @@ int ExportMusicXml::findBracket(const TextLineBase* tl) const

void ExportMusicXml::textLine(TextLineBase const* const tl, int staff, const Fraction& tick)
{
if (!tl->lineVisible() && ((tl->beginText().isEmpty() && tl->tick() == tick)
|| (tl->endText().isEmpty() && tl->tick() != tick)))
return;

int n;
// special case: a dashed line w/o hooks is written as dashes
const auto isDashes = tl->lineStyle() == Qt::DashLine && (tl->beginHookType() == HookType::NONE) && (tl->endHookType() == HookType::NONE);
Expand Down Expand Up @@ -4924,12 +4932,14 @@ void ExportMusicXml::textLine(TextLineBase const* const tl, int staff, const Fra
_xml.etag();
}

_xml.stag("direction-type");
if (isDashes)
_xml.tagE(QString("dashes type=\"%1\" number=\"%2\"").arg(type, QString::number(n + 1)));
else
_xml.tagE(QString("bracket type=\"%1\" number=\"%2\" line-end=\"%3\"%4").arg(type, QString::number(n + 1), lineEnd, rest));
_xml.etag();
if (tl->lineVisible()) {
_xml.stag("direction-type");
if (isDashes)
_xml.tagE(QString("dashes type=\"%1\" number=\"%2\"").arg(type, QString::number(n + 1)));
else
_xml.tagE(QString("bracket type=\"%1\" number=\"%2\" line-end=\"%3\"%4").arg(type, QString::number(n + 1), lineEnd, rest));
_xml.etag();
}

if (!tl->endText().isEmpty() && tl->tick() != tick) {
_xml.stag("direction-type");
Expand Down
2 changes: 0 additions & 2 deletions mtest/musicxml/io/testColorExport_ref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@
</ornaments>
</notations>
</note>
<direction placement="below">
</direction>
</measure>
<measure number="6">
<direction placement="below">
Expand Down

0 comments on commit 7a88317

Please sign in to comment.