Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault when deleting the last history playlist under a year folder #4298

Merged
merged 1 commit into from
Sep 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/library/trackset/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
@@ -361,14 +361,16 @@ void BasePlaylistFeature::slotCreatePlaylist() {
/// Returns a playlist that is a sibling inside the same parent
/// as the start index
int BasePlaylistFeature::getSiblingPlaylistIdOf(QModelIndex& start) {
for (int i = start.row() + 1; i >= (start.row() - 1); i -= 2) {
QModelIndex nextIndex = start.sibling(i, start.column());
if (nextIndex.isValid()) {
TreeItem* pTreeItem = m_pSidebarModel->getItem(nextIndex);
DEBUG_ASSERT(pTreeItem != nullptr);
if (!pTreeItem->hasChildren()) {
return playlistIdFromIndex(nextIndex);
}
QModelIndex nextIndex = start.sibling(start.row() + 1, start.column());
if (!nextIndex.isValid() && start.row() > 0) {
// No playlist below, looking above.
nextIndex = start.sibling(start.row() - 1, start.column());
}
if (nextIndex.isValid()) {
TreeItem* pTreeItem = m_pSidebarModel->getItem(nextIndex);
DEBUG_ASSERT(pTreeItem != nullptr);
if (!pTreeItem->hasChildren()) {
return playlistIdFromIndex(nextIndex);
}
}
return kInvalidPlaylistId;