From bd395cc5a669e4f8dfdbe1a0632f2254e735b59c Mon Sep 17 00:00:00 2001 From: Craig Drummond Date: Mon, 14 Dec 2015 22:16:51 +0000 Subject: [PATCH] Fix 'Locate In Library' for Single Tracks --- models/sqllibrarymodel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/models/sqllibrarymodel.cpp b/models/sqllibrarymodel.cpp index 73ca007be..26329470a 100644 --- a/models/sqllibrarymodel.cpp +++ b/models/sqllibrarymodel.cpp @@ -452,6 +452,16 @@ QModelIndex SqlLibraryModel::findSongIndex(const Song &song) } } } + + // Hmm... Find song details in db via file path - fixes SingleTracks songs + if (!song.file.isEmpty()) { + QList dbSongs=db->songs(QStringList() << song.file); + if (!dbSongs.isEmpty() && dbSongs.first().albumId()!=song.albumId()) { + Song dbSong=dbSongs.first(); + dbSong.file=QString(); // Prevent recursion! + return findSongIndex(dbSong); + } + } return QModelIndex(); }