Skip to content

Commit

Permalink
Crates: only store or activate sibling crate if it's valid
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jul 28, 2023
1 parent cde8402 commit db8ce6a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/library/trackset/crate/cratefeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,10 @@ void CrateFeature::storePrevSiblingCrateId(CrateId crateId) {
TreeItem* pTreeItem = m_pSidebarModel->getItem(newIndex);
DEBUG_ASSERT(pTreeItem != nullptr);
if (!pTreeItem->hasChildren()) {
m_prevSiblingCrate = crateIdFromIndex(newIndex);
CrateId prevCrateId = crateIdFromIndex(newIndex);
if (prevCrateId.isValid()) {
m_prevSiblingCrate = prevCrateId;
}
}
}
}
Expand All @@ -877,7 +880,9 @@ void CrateFeature::slotCrateTableChanged(CrateId crateId) {
if (!activateCrate(m_crateTableModel.selectedCrate())) {
// probably last clicked crate was deleted, try to
// select the stored sibling
activateCrate(m_prevSiblingCrate);
if (m_prevSiblingCrate.isValid()) {
activateCrate(m_prevSiblingCrate);
}
}
} else {
// No valid selection to restore
Expand Down

0 comments on commit db8ce6a

Please sign in to comment.