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, toNoteLine
and toTextLine in the due course
  • Loading branch information
Jojo-Schmitz committed Jun 24, 2016
1 parent ae37ad9 commit 24c8ee5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
12 changes: 6 additions & 6 deletions libmscore/cmd.cpp
Expand Up @@ -291,12 +291,12 @@ 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->isTextLine()
|| spanner->isNoteLine()
|| spanner->isOttava()
|| spanner->isPedal()
|| spanner->isHairpin()
|| spanner->isVolta()) {
// rebase text elements to score style
TextLine* tl = toTextLine(spanner);
TextStyleType st;
Expand Down
16 changes: 15 additions & 1 deletion libmscore/element.h
Expand Up @@ -94,6 +94,7 @@ class DurationElement;
class Accidental;
class TextLine;
class Pedal;
class NoteLine;

enum class SymId;

Expand Down Expand Up @@ -706,6 +707,7 @@ class Element : public QObject, public ScoreElement {
CONVERT(TextLine, TEXTLINE)
CONVERT(Pedal, PEDAL)
CONVERT(OttavaSegment, OTTAVA_SEGMENT)
CONVERT(NoteLine, NOTELINE)
#undef CONVERT
};

Expand All @@ -732,6 +734,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* toTextLine(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* toTextLine(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 @@ -788,9 +802,9 @@ 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(Pedal, PEDAL)
CONVERT(OttavaSegment, OTTAVA_SEGMENT)
CONVERT(NoteLine, NOTELINE)
#undef CONVERT

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

0 comments on commit 24c8ee5

Please sign in to comment.