fix #14722: fixed an incorrect check on the main instrument

This commit is contained in:
Roman Pudashkin 2022-11-28 15:00:09 +02:00
parent c907d0dc6d
commit d795668dc2
6 changed files with 8 additions and 4 deletions

View file

@ -42,6 +42,7 @@ using namespace mu;
using namespace mu::engraving;
namespace mu::engraving {
const Fraction Part::MAIN_INSTRUMENT_TICK = Fraction(-1, 1);
//---------------------------------------------------------
// Part
//---------------------------------------------------------

View file

@ -87,6 +87,8 @@ class Part final : public EngravingObject
friend class compat::Read206;
public:
static const Fraction MAIN_INSTRUMENT_TICK;
Part(Score* score = nullptr);
void initFromInstrTemplate(const InstrumentTemplate*);

View file

@ -42,6 +42,7 @@ void InstrumentSettingsModel::load(const QVariant& instrument)
QVariantMap map = instrument.toMap();
m_instrumentKey.partId = ID(map["partId"]);
m_instrumentKey.instrumentId = map["instrumentId"].toString();
m_instrumentKey.tick = Part::MAIN_INSTRUMENT_TICK;
const Part* part = notationParts()->part(m_instrumentKey.partId);
if (!part) {

View file

@ -144,7 +144,7 @@ void MasterNotationParts::replaceInstrument(const InstrumentKey& instrumentKey,
startGlobalEdit();
const Part* part = partModifiable(instrumentKey.partId);
bool isMainInstrument = part && isMainInstrumentForPart(instrumentKey.instrumentId, part);
bool isMainInstrument = part && isMainInstrumentForPart(instrumentKey, part);
NotationParts::replaceInstrument(instrumentKey, newInstrument);

View file

@ -560,7 +560,7 @@ void NotationParts::replaceInstrument(const InstrumentKey& instrumentKey, const
startEdit();
if (isMainInstrumentForPart(instrumentKey.instrumentId, part)) {
if (isMainInstrumentForPart(instrumentKey, part)) {
mu::engraving::Interval oldTranspose = part->instrument()->transpose();
QString newInstrumentPartName = formatInstrumentTitle(newInstrument.trackName(), newInstrument.trait());

View file

@ -348,9 +348,9 @@ struct InstrumentKey
Fraction tick = mu::engraving::Fraction(0, 1);
};
inline bool isMainInstrumentForPart(const QString& instrumentId, const Part* part)
inline bool isMainInstrumentForPart(const InstrumentKey& instrumentKey, const Part* part)
{
return instrumentId == part->instrumentId();
return instrumentKey.instrumentId == part->instrumentId() && instrumentKey.tick == Part::MAIN_INSTRUMENT_TICK;
}
inline QString formatInstrumentTitle(const QString& instrumentName, const InstrumentTrait& trait)