Skip to content

Commit

Permalink
fix #116196: Crash applying line via double click (debug build)
Browse files Browse the repository at this point in the history
adding and using the proper CONVERT macros for isNoteLine() and
toNoteLine()
as well as methods for isTextLineType() and toTextLineType() in the due
course
  • Loading branch information
Jojo-Schmitz committed Jul 10, 2016
1 parent 3172717 commit 69a89c2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
9 changes: 2 additions & 7 deletions libmscore/cmd.cpp
Expand Up @@ -291,14 +291,9 @@ void Score::cmdAddSpanner(Spanner* spanner, int staffIdx, Segment* startSegment,
else
tick2 = endSegment->tick();
spanner->setTick2(tick2);
if (spanner->type() == Element::Type::TEXTLINE
|| spanner->type() == Element::Type::NOTELINE
|| spanner->type() == Element::Type::OTTAVA
|| spanner->type() == Element::Type::PEDAL
|| spanner->type() == Element::Type::HAIRPIN
|| spanner->type() == Element::Type::VOLTA) {
if (spanner->isTextLineType()) {
// rebase text elements to score style
TextLine* tl = toTextLine(spanner);
TextLine* tl = toTextLineType(spanner);
TextStyleType st;
Text* t;
// begin
Expand Down
22 changes: 21 additions & 1 deletion libmscore/element.h
Expand Up @@ -98,6 +98,7 @@ class Pedal;
class LedgerLine;
class Icon;
class VoltaSegment;
class NoteLine;

enum class SymId;

Expand Down Expand Up @@ -654,6 +655,11 @@ class Element : public QObject, public ScoreElement {
bool isDurationElement() const { return isChordRest() || (type() == Element::Type::TUPLET); }
bool isSLine() const;
bool isSLineSegment() const;
bool isTextLineType() const {
return type() == Element::Type::TEXTLINE || type() == Element::Type::NOTELINE
|| type() == Element::Type::OTTAVA || type() == Element::Type::PEDAL
|| type() == Element::Type::HAIRPIN || type() == Element::Type::VOLTA;
}

#define CONVERT(a,b) \
bool is##a() const { return type() == Element::Type::b; }
Expand Down Expand Up @@ -714,6 +720,7 @@ class Element : public QObject, public ScoreElement {
CONVERT(LedgerLine, LEDGER_LINE)
CONVERT(Icon, ICON)
CONVERT(VoltaSegment, VOLTA_SEGMENT)
CONVERT(NoteLine, NOTELINE)
#undef CONVERT
};

Expand All @@ -740,6 +747,18 @@ static inline const DurationElement* toDurationElement(const Element* e) {
|| e->type() == Element::Type::REPEAT_MEASURE || e->type() == Element::Type::TUPLET);
return (const DurationElement*)e;
}
static inline TextLine* toTextLineType(Element* e) {
Q_ASSERT(e == 0 || e->type() == Element::Type::TEXTLINE || e->type() == Element::Type::NOTELINE
|| e->type() == Element::Type::OTTAVA || e->type() == Element::Type::PEDAL
|| e->type() == Element::Type::HAIRPIN || e->type() == Element::Type::VOLTA);
return (TextLine*)e;
}
static inline const TextLine* toTextLineType(const Element* e) {
Q_ASSERT(e == 0 || e->type() == Element::Type::TEXTLINE || e->type() == Element::Type::NOTELINE
|| e->type() == Element::Type::OTTAVA || e->type() == Element::Type::PEDAL
|| e->type() == Element::Type::HAIRPIN || e->type() == Element::Type::VOLTA);
return (const TextLine*)e;
}

#define CONVERT(a,b) \
static inline a* to##a(Element* e) { Q_ASSERT(e == 0 || e->type() == Element::Type::b); return (a*)e; } \
Expand Down Expand Up @@ -796,12 +815,13 @@ static inline const a* to##a(const Element* e) { Q_ASSERT(e == 0 || e->type() ==
CONVERT(Dynamic, DYNAMIC)
CONVERT(InstrumentName, INSTRUMENT_NAME)
CONVERT(Accidental, ACCIDENTAL)
CONVERT(TextLine, TEXTLINE)
CONVERT(TextLine, TEXTLINE)
CONVERT(Pedal, PEDAL)
CONVERT(OttavaSegment, OTTAVA_SEGMENT)
CONVERT(LedgerLine, LEDGER_LINE)
CONVERT(Icon, ICON)
CONVERT(VoltaSegment, VOLTA_SEGMENT)
CONVERT(NoteLine, NOTELINE)
#undef CONVERT

//---------------------------------------------------------
Expand Down

0 comments on commit 69a89c2

Please sign in to comment.