Skip to content

Commit

Permalink
disallow to deselect all voices when creating parts, fix crash when d…
Browse files Browse the repository at this point in the history
…ouble clicking staff lines in part list
  • Loading branch information
lasconic committed Sep 14, 2016
1 parent 4c5ada5 commit 67b189f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,8 @@ void MasterScore::addExcerpt(Score* score, QMultiMap<int, int>& tracks, Excerpt*
}
}
}
if (tracks.isEmpty()) {
if (tracks.isEmpty()) { // SHOULDN'T HAPPEN, protected in the UI
qDebug() << "Empty tracklist when adding excerpt. Something is wrong.";
for (Staff* s : score->staves()) {
LinkedStaves* ls = s->linkedStaves();
if (ls == 0)
Expand Down
23 changes: 21 additions & 2 deletions mscore/excerptsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ StaffItem::StaffItem(PartItem* li)
}
}

void StaffItem::setData(int column, int role, const QVariant& value)
{
const bool isCheckChange = column > 0
&& role == Qt::CheckStateRole
&& data(column, role).isValid() // Don't "change" during initialization
&& checkState(column) != value;
QTreeWidgetItem::setData(column, role, value);
if (isCheckChange) {
int unchecked = 0;
for (int i = 1; i <= VOICES; i++) {
if (checkState(i) == Qt::Unchecked)
unchecked += 1;
}
if (unchecked == VOICES)
setCheckState(column, Qt::Checked);
}
}
//---------------------------------------------------------
// ExcerptsDialog
//---------------------------------------------------------
Expand Down Expand Up @@ -340,8 +357,10 @@ void ExcerptsDialog::partDoubleClicked(QTreeWidgetItem* item, int)
{
if (!title->isEnabled())
return;
PartItem* pi = (PartItem*)item;
title->setText(pi->part()->partName());
if (!item->parent()) { // top level items are PartItem
PartItem* pi = (PartItem*)item;
title->setText(pi->part()->partName());
}
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mscore/excerptsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class StaffItem : public QTreeWidgetItem {

Staff* staff() const { return _staff; }
void setStaff(Staff* s) { _staff = s; }
void setData(int column, int role, const QVariant& value) override;
};

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

0 comments on commit 67b189f

Please sign in to comment.