Skip to content

Commit

Permalink
fix #33341
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Sep 23, 2014
1 parent d9331b6 commit df67515
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
3 changes: 1 addition & 2 deletions libmscore/cmd.cpp
Expand Up @@ -2313,9 +2313,8 @@ void Score::cmd(const QAction* a)
deselectAll();
undo(new ChangeStyleVal(this, StyleIdx::createMultiMeasureRests, val));
}
else if (cmd == "add-brackets") {
else if (cmd == "add-brackets")
cmdAddBracket();
}
else
qDebug("unknown cmd <%s>", qPrintable(cmd));
}
Expand Down
28 changes: 23 additions & 5 deletions libmscore/score.cpp
Expand Up @@ -2909,8 +2909,20 @@ void Score::collectMatch(void* data, Element* e)
ElementPattern* p = static_cast<ElementPattern*>(data);
if (p->type != int(e->type()))
return;
if (p->subtypeValid && p->subtype != e->subtype())
return;

if (p->subtypeValid) {
// HACK: grace note is different from normal note
// TODO: this disables the ability to distinguish note heads in subtype

if (p->type == int(Element::Type::NOTE)) {
if (p->subtype != static_cast<Note*>(e)->chord()->isGrace())
return;
}
else {
if (p->subtype != e->subtype())
return;
}
}
if ((p->staffStart != -1)
&& ((p->staffStart > e->staffIdx()) || (p->staffEnd <= e->staffIdx())))
return;
Expand Down Expand Up @@ -2942,9 +2954,15 @@ void Score::selectSimilar(Element* e, bool sameStaff)
Score* score = e->score();

ElementPattern pattern;
pattern.type = int(type);
pattern.subtype = 0;
pattern.subtypeValid = false;
pattern.type = int(type);
if (type == Element::Type::NOTE) {
pattern.subtype = static_cast<Note*>(e)->chord()->isGrace();
pattern.subtypeValid = true;
}
else {
pattern.subtype = 0;
pattern.subtypeValid = false;
}
pattern.staffStart = sameStaff ? e->staffIdx() : -1;
pattern.staffEnd = sameStaff ? e->staffIdx()+1 : -1;
pattern.voice = -1;
Expand Down
7 changes: 6 additions & 1 deletion mscore/inspector/inspector.cpp
Expand Up @@ -130,11 +130,16 @@ void Inspector::setElements(const QList<Element*>& l)
if (_element == 0)
ie = new InspectorEmpty(this);


bool sameTypes = true;
foreach(Element* ee, _el) {
if (_element->type() != ee->type())
sameTypes = false;
else {
// HACK:
if (ee->type() == Element::Type::NOTE
&& static_cast<Note*>(ee)->chord()->isGrace() != static_cast<Note*>(_element)->chord()->isGrace())
sameTypes = false;
}
}
if (!sameTypes)
ie = new InspectorGroupElement(this);
Expand Down

2 comments on commit df67515

@lasconic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that it fixes the crash but it's a pity we can't select all the notes (grace or not) to change their color or visibility :(
Wouldn't be better to remove the qfatal and replace it by a qDebug or qWarning when getting to the chord and trying to change the trailing space of it (which is not possible)?.
I mean here

qFatal("Element::setProperty: unknown <%s>(%hhd), data <%s>",

if we really want to qFatal we could test if the element is a chord and the property trailing space... it's ugly but it fixes the bug and doesn't remove any feature.

@wschweer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It adds the feature of selecting all normal notes and all grace notes :-)

Please sign in to comment.