Skip to content

Commit

Permalink
Fix #25958 - Crash when [Apply]ing and [OK]ing some prop changes
Browse files Browse the repository at this point in the history
Additional fixes:

- Changes to staff own properties (small, invisible, user dist., colour) were not carried on.
- Changes to staff type when not visibly laid out into the score.
- Finally time sigs are re-laid out when staff type changes.
- If short and long names are empty strings, instrument relevant lists are no longer set to an empty string; rather the relevant list is left empty; this matches the situation when the dlg is open with either name not set and avoids unnecessary ChangePart undoes.
  • Loading branch information
mgavioli committed Jun 6, 2014
1 parent 6081ff8 commit d8ebc4c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
6 changes: 4 additions & 2 deletions libmscore/instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,8 @@ void InstrumentData::setDrumset(Drumset* ds)
void InstrumentData::setLongName(const QString& f)
{
_longNames.clear();
_longNames.append(StaffName(f, 0));
if (f.length() > 0)
_longNames.append(StaffName(f, 0));
}

//---------------------------------------------------------
Expand All @@ -682,7 +683,8 @@ void InstrumentData::setLongName(const QString& f)
void InstrumentData::setShortName(const QString& f)
{
_shortNames.clear();
_shortNames.append(StaffName(f, 0));
if (f.length() > 0)
_shortNames.append(StaffName(f, 0));
}

//---------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,9 @@ void ChangeStaffType::redo()
StaffType st = *staff->staffType();
staff->setStaffType(&staffType);
staffType = st;
Score* score = staff->score();
score->setLayoutAll(true);
score->scanElements(0, notifyTimeSigs);
}

void ChangeStaffType::undo()
Expand Down Expand Up @@ -2392,6 +2395,8 @@ void ChangeStaffType::undo()
seg->add(clef);
}
// cmdUpdateNotes(); // needed?
score->setLayoutAll(true);
score->scanElements(0, notifyTimeSigs);
}

//---------------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions mscore/editstaff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ void EditStaff::updateInstrument()
{
updateInterval(instrument.transpose());

QList<StaffName>& nl = instrument.shortNames();
QString df = nl.isEmpty() ? "" : nl[0].name;
QList<StaffName>& snl = instrument.shortNames();
QString df = snl.isEmpty() ? "" : snl[0].name;
shortName->setText(df);

nl = instrument.longNames();
df = nl.isEmpty() ? "" : nl[0].name;
QList<StaffName>& lnl = instrument.longNames();
df = lnl.isEmpty() ? "" : lnl[0].name;
longName->setText(df);

if (partName->text() == instrumentName->text()) // Updates part name is no custom name has been set before
if (partName->text() == instrumentName->text()) // Updates part name if no custom name has been set before
partName->setText(instrument.trackName());

instrumentName->setText(instrument.trackName());
Expand Down Expand Up @@ -191,14 +191,14 @@ void EditStaff::bboxClicked(QAbstractButton* button)

case QDialogButtonBox::RejectRole:
close();
if (staff != nullptr)
delete staff;
break;

default:
qDebug("EditStaff: unknown button %d", int(br));
break;
}
if (staff != nullptr)
delete staff;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -245,7 +245,7 @@ void EditStaff::apply()
}

if (s != staff->small() || inv != staff->invisible() || userDist != staff->userDist() || col != staff->color())
score->undo(new ChangeStaff(staff, s, inv, userDist * score->spatium(), col));
score->undo(new ChangeStaff(orgStaff, s, inv, userDist * score->spatium(), col));

if ( !(*orgStaff->staffType() == *staff->staffType()) ) {
// updateNeeded |= (orgStaff->staffGroup() == StaffGroup::TAB || staff->staffGroup() == StaffGroup::TAB);
Expand Down

0 comments on commit d8ebc4c

Please sign in to comment.