Skip to content

Commit 81efb49

Browse files
committed
Fix crash in SVG export with tapping
It was calling `TDraw::draw(const Tapping* item, …)` on a `Tapping` with neither a symbol nor Text but only a TappingHalfSlur. In that case, the half slur is drawn via `TDraw::draw(const SlurSegment* item, …)`, and the `Tapping` itself is not drawn at all because its bbox is empty, and elements with empty bbox are normally filtered out for drawing by `BspTree::items`, which checks for `bbox` intersection with the viewport rect, and empty RectF never intersects. Added a similar bbox check in SVG export, and added a super light safety check in TDraw as well. Resolves: #29257
1 parent ad09c45 commit 81efb49

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/engraving/rendering/score/tdraw.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,11 +2984,12 @@ void TDraw::draw(const Tapping* item, muse::draw::Painter* painter)
29842984
painter->setPen(item->curColor());
29852985
if (item->ldata()->symId != SymId::noSym) {
29862986
item->drawSymbol(item->ldata()->symId, painter);
2987-
} else {
2988-
TappingText* text = item->text();
2987+
} else if (TappingText* text = item->text()) {
29892988
painter->translate(text->pos());
29902989
drawTextBase(text, painter);
29912990
painter->translate(-text->pos());
2991+
} else {
2992+
assert(false && "Drawing Tapping item without text or symbol");
29922993
}
29932994
}
29942995

src/importexport/imagesexport/internal/svgwriter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ Ret SvgWriter::write(INotationPtr notation, io::IODevice& destinationDevice, con
240240
continue;
241241
}
242242

243+
// Match BspTree::items, which checks for bbox intersection
244+
// and empty RectF intersects with nothing
245+
if (element->ldata()->bbox().isEmpty()) {
246+
continue;
247+
}
248+
243249
mu::engraving::ElementType type = element->type();
244250
switch (type) { // In future sub-type code, this switch() grows, and eType gets used
245251
case mu::engraving::ElementType::STAFF_LINES: // Handled in the 1st pass above

0 commit comments

Comments
 (0)