Skip to content

Commit

Permalink
Merge pull request musescore#18429 from Eism/nsw_select_first_group_fix
Browse files Browse the repository at this point in the history
fixed musescore#18427: No instrument category selected when opening New Score dialog
  • Loading branch information
DmitryArefiev committed Jul 6, 2023
2 parents 1181e50 + 473b974 commit 9bc47d3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/instrumentsscene/view/instrumentlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using namespace mu::uicomponents;

static const QString ALL_INSTRUMENTS_GENRE_ID("ALL_INSTRUMENTS");
static const QString NONE_GROUP_ID("");
static const QString FIRST_GROUP_ID("FIRST_GROUP_ID");
static const QString INSTRUMENT_TEMPLATE_KEY("instrumentTemplate");

InstrumentListModel::InstrumentListModel(QObject* parent)
Expand Down Expand Up @@ -135,7 +136,7 @@ void InstrumentListModel::load(bool canSelectMultipleInstruments, const QString&
loadGroups();

if (currentInstrumentId.isEmpty()) {
init(COMMON_GENRE_ID, NONE_GROUP_ID);
init(COMMON_GENRE_ID, FIRST_GROUP_ID);
} else {
init(COMMON_GENRE_ID, resolveInstrumentGroupId(currentInstrumentId));
}
Expand Down Expand Up @@ -168,7 +169,13 @@ void InstrumentListModel::init(const QString& genreId, const QString& groupId)
TRACEFUNC;

setCurrentGenre(genreId);
setCurrentGroup(groupId);

QString newGroupId = groupId;
if (newGroupId == FIRST_GROUP_ID) {
newGroupId = !m_groups.empty() ? m_groups.first()->id.toQString() : NONE_GROUP_ID;
}

setCurrentGroup(newGroupId);

m_instrumentsLoadingAllowed = true;
loadInstruments();
Expand Down

0 comments on commit 9bc47d3

Please sign in to comment.