Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #305134: crash on chordsymbol playback #6071

Merged
merged 2 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libmscore/instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@

namespace Ms {

const char* Channel::DEFAULT_NAME = QT_TRANSLATE_NOOP("channel", "Normal");
const char* Channel::HARMONY_NAME = QT_TRANSLATE_NOOP("channel", "Chord symbols");
//: Channel name for otherwise unamed channels
const char* Channel::DEFAULT_NAME = QT_TRANSLATE_NOOP("InstrumentsXML", "normal");
//: Channel name for the chord symbols playback channel, best keep translation shorter than 11 letters
const char* Channel::HARMONY_NAME = QT_TRANSLATE_NOOP("InstrumentsXML", "harmony");

Instrument InstrumentList::defaultInstrument;
const std::initializer_list<Channel::Prop> PartChannelSettingsLink::excerptProperties {
Expand Down
20 changes: 10 additions & 10 deletions libmscore/part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ void Part::updateHarmonyChannels(bool isDoOnInstrumentChanged, bool checkRemoval
if (!harmonyChannel() && harmonyCount() > 0) {
Instrument* instr = instrument();
Channel* c = new Channel(*instr->channel(0));
c->setName(qApp->translate("channel", Channel::HARMONY_NAME));
c->setName(Channel::HARMONY_NAME);
Jojo-Schmitz marked this conversation as resolved.
Show resolved Hide resolved
instr->appendChannel(c);
onInstrumentChanged();
}
Expand All @@ -610,17 +610,17 @@ void Part::updateHarmonyChannels(bool isDoOnInstrumentChanged, bool checkRemoval

const Channel* Part::harmonyChannel() const
{
const Instrument* instr = instrument();
if (!instr)
return nullptr;
const Instrument* instr = instrument();
if (!instr)
return nullptr;

int chanIdx = instr->channelIdx(Channel::HARMONY_NAME);
if (chanIdx == -1)
return nullptr;
int chanIdx = instr->channelIdx(Channel::HARMONY_NAME);
if (chanIdx == -1)
return nullptr;

const Channel* chan = instr->channel(chanIdx);
Q_ASSERT(chan);
return chan;
const Channel* chan = instr->channel(chanIdx);
Q_ASSERT(chan);
return chan;
Jojo-Schmitz marked this conversation as resolved.
Show resolved Hide resolved
}

//---------------------------------------------------------
Expand Down
13 changes: 5 additions & 8 deletions mscore/articulationprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,11 @@ ArticulationProperties::ArticulationProperties(Articulation* na, QWidget* parent
// const QList<Channel>& channel() const;

for (const Channel* a : instrument->channel()) {
if (a->name().isEmpty() || a->name() == Channel::DEFAULT_NAME) {
channelList->addItem(qApp->translate("channel", Channel::DEFAULT_NAME));
channelList->item(channelList->count() - 1)->setData(Qt::UserRole, Channel::DEFAULT_NAME);
}
else {
channelList->addItem(qApp->translate("InstrumentsXML", a->name().toUtf8().data()));
channelList->item(channelList->count() - 1)->setData(Qt::UserRole, a->name());
}
QString name = a->name();
if (a->name().isEmpty())
name = Channel::DEFAULT_NAME;
channelList->addItem(qApp->translate("InstrumentsXML", name.toUtf8().data()));
channelList->item(channelList->count() - 1)->setData(Qt::UserRole, name);
}
for (const NamedEventList& el : instrument->midiActions()) {
midiActionList->addItem(qApp->translate("InstrumentsXML", el.name.toUtf8().data()));
Expand Down
42 changes: 18 additions & 24 deletions mscore/stafftextproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ static void initChannelCombo(QComboBox* cb, StaffTextBase* st)
Part* part = st->staff()->part();
Fraction tick = static_cast<Segment*>(st->parent())->tick();
for (const Channel* a : part->instrument(tick)->channel()) {
if (a->name().isEmpty() || a->name() == Channel::DEFAULT_NAME)
cb->addItem(qApp->translate("channel", Channel::DEFAULT_NAME));
else
cb->addItem(qApp->translate("InstrumentsXML", a->name().toUtf8().data()));
QString name = a->name();
if (a->name().isEmpty())
name = Channel::DEFAULT_NAME;
cb->addItem(qApp->translate("InstrumentsXML", name.toUtf8().data()));
}
}

Expand Down Expand Up @@ -184,10 +184,10 @@ StaffTextProperties::StaffTextProperties(const StaffTextBase* st, QWidget* paren
const Channel* a = part->instrument(tick)->channel(i);
QTreeWidgetItem* item = new QTreeWidgetItem(channelList);
item->setData(0, Qt::UserRole, i);
if (a->name().isEmpty() || a->name() == Channel::DEFAULT_NAME)
item->setText(0, qApp->translate("channel", Channel::DEFAULT_NAME));
else
item->setText(0, qApp->translate("InstrumentsXML", a->name().toUtf8().data()));
QString name = a->name();
if (a->name().isEmpty())
name == Channel::DEFAULT_NAME;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is supposed to be assignment, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Outch... Of course

item->setText(0, qApp->translate("InstrumentsXML", name.toUtf8().data()));
item->setText(1, qApp->translate("InstrumentsXML", a->descr().toUtf8().data()));
if (i == 0)
selectedItem = item;
Expand Down Expand Up @@ -388,26 +388,20 @@ void StaffTextProperties::channelItemChanged(QTreeWidgetItem* item, QTreeWidgetI

for (const NamedEventList& e : part->instrument(tick)->midiActions()) {
QTreeWidgetItem* ti = new QTreeWidgetItem(actionList);
if (e.name.isEmpty() || e.name == Channel::DEFAULT_NAME) {
ti->setText(0, qApp->translate("channel", Channel::DEFAULT_NAME));
ti->setData(0, Qt::UserRole, Channel::DEFAULT_NAME);
}
else {
ti->setText(0, qApp->translate("InstrumentsXML", e.name.toUtf8().data()));
ti->setData(0, Qt::UserRole, e.name);
}
QString name = e.name;
if (e.name.isEmpty())
name == Channel::DEFAULT_NAME;
Copy link
Contributor

Choose a reason for hiding this comment

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

And here?

ti->setText(0, qApp->translate("InstrumentsXML", name.toUtf8().data()));
ti->setData(0, Qt::UserRole, name);
ti->setText(1, qApp->translate("InstrumentsXML", e.descr.toUtf8().data()));
}
for (const NamedEventList& e : channel->midiActions) {
QTreeWidgetItem* ti = new QTreeWidgetItem(actionList);
if (e.name.isEmpty() || e.name == Channel::DEFAULT_NAME) {
ti->setText(0, qApp->translate("channel", Channel::DEFAULT_NAME));
ti->setData(0, Qt::UserRole, Channel::DEFAULT_NAME);
}
else {
ti->setText(0, qApp->translate("InstrumentsXML", e.name.toUtf8().data()));
ti->setData(0, Qt::UserRole, e.name);
}
QString name = e.name;
if (e.name.isEmpty())
name == Channel::DEFAULT_NAME;
Copy link
Contributor

Choose a reason for hiding this comment

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

And here?

ti->setText(0, qApp->translate("InstrumentsXML", name.toUtf8().data()));
ti->setData(0, Qt::UserRole, name);
ti->setText(1, qApp->translate("InstrumentsXML", e.descr.toUtf8().data()));
}
for (const ChannelActions& ca : *_staffText->channelActions()) {
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/add-link-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<Channel>
<program value="24"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="24"/>
</Channel>
</Instrument>
Expand Down
4 changes: 2 additions & 2 deletions mtest/libmscore/chordsymbol/add-part-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Channel>
<program value="24"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="24"/>
</Channel>
</Instrument>
Expand Down Expand Up @@ -161,7 +161,7 @@
<Channel>
<program value="24"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="24"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/clear.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Channel>
<program value="27"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="27"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/extend-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Channel>
<program value="27"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="27"/>
</Channel>
</Instrument>
Expand Down
4 changes: 2 additions & 2 deletions mtest/libmscore/chordsymbol/no-system-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Channel>
<program value="65"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="65"/>
</Channel>
</Instrument>
Expand Down Expand Up @@ -357,7 +357,7 @@
<Channel>
<program value="65"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="65"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-3note-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-4note-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-6note-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-close-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-concert-pitch-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-drop2-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-duration-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-duration.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-jazz-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<controller ctrl="32" value="0"/>
<program value="4"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<controller ctrl="0" value="0"/>
<controller ctrl="32" value="0"/>
<program value="4"/>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-jazz.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<controller ctrl="32" value="0"/>
<program value="4"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<controller ctrl="0" value="0"/>
<controller ctrl="32" value="0"/>
<program value="4"/>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-override-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-override.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-transpose-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<Channel>
<program value="73"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="73"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-triplet-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/realize-triplet.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<Channel>
<program value="0"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="0"/>
</Channel>
</Instrument>
Expand Down
4 changes: 2 additions & 2 deletions mtest/libmscore/chordsymbol/transpose-part-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<Channel>
<program value="73"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="73"/>
</Channel>
</Instrument>
Expand Down Expand Up @@ -181,7 +181,7 @@
<Channel>
<program value="73"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="73"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/chordsymbol/transpose-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<Channel>
<program value="73"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="73"/>
</Channel>
</Instrument>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/compat114/chord_symbol-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="73"/>
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
Expand Down
2 changes: 1 addition & 1 deletion mtest/libmscore/compat114/text_scaling-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="73"/>
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
Expand Down
4 changes: 2 additions & 2 deletions mtest/libmscore/compat206/lidemptytext-ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<Channel name="tremolo">
<program value="44"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="43"/>
</Channel>
</Instrument>
Expand Down Expand Up @@ -350,7 +350,7 @@
<Channel name="tremolo">
<program value="44"/>
</Channel>
<Channel name="Chord symbols">
<Channel name="harmony">
<program value="43"/>
</Channel>
</Instrument>
Expand Down
Loading