Unlock DB mutexes implicitly using scopes. Add error handling for query.

This commit is contained in:
santigl 2017-03-06 15:10:41 -03:00 committed by John Maguire
parent f5bd7ef5c0
commit a8cbb3b18a
1 changed files with 12 additions and 8 deletions

View File

@ -536,10 +536,12 @@ QStringList LibraryBackend::GetAllArtistsWithAlbums(const QueryOptions& opt) {
query2.AddWhere("album", "", "!=");
query2.AddWhere("albumartist", "", "=");
QMutexLocker l(db_->Mutex());
ExecQuery(&query);
ExecQuery(&query2);
l.unlock();
{
QMutexLocker l(db_->Mutex());
if (!ExecQuery(&query) || !ExecQuery(&query2)) {
return QStringList();
}
}
QSet<QString> artists;
while (query.Next()) {
@ -870,12 +872,14 @@ LibraryBackend::AlbumList LibraryBackend::GetAlbums(const QString& artist,
query.AddWhere("artist", artist);
}
QMutexLocker l(db_->Mutex());
if (!ExecQuery(&query)) return ret;
l.unlock();
{
QMutexLocker l(db_->Mutex());
if (!ExecQuery(&query)) return ret;
}
QString last_album;
QString last_artist, last_album_artist;
QString last_artist;
QString last_album_artist;
while (query.Next()) {
bool compilation = query.Value(3).toBool() | query.Value(4).toBool();