From 29072797ca5a397b2878e458db22cb5dcc7dfe4d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 1 Feb 2014 01:11:50 +0100 Subject: db/DatabasePlaylist: pass Database reference around Reduce global variable usage, move to frontend code. --- src/command/DatabaseCommands.cxx | 7 ++++++- src/command/PlaylistCommands.cxx | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/command') diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index 2b871e565..b458b3756 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "DatabaseCommands.hxx" +#include "db/DatabaseGlue.hxx" #include "db/DatabaseQueue.hxx" #include "db/DatabasePlaylist.hxx" #include "db/DatabasePrint.hxx" @@ -119,7 +120,11 @@ handle_searchaddpl(Client &client, int argc, char *argv[]) } Error error; - return search_add_to_playlist("", playlist, &filter, error) + const Database *db = GetDatabase(error); + if (db == nullptr) + return print_error(client, error); + + return search_add_to_playlist(*db, "", playlist, &filter, error) ? CommandResult::OK : print_error(client, error); } diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx index 10dfff876..07cc177d6 100644 --- a/src/command/PlaylistCommands.cxx +++ b/src/command/PlaylistCommands.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "PlaylistCommands.hxx" +#include "db/DatabaseGlue.hxx" #include "db/DatabasePlaylist.hxx" #include "CommandError.hxx" #include "PlaylistPrint.hxx" @@ -192,7 +193,11 @@ handle_playlistadd(Client &client, gcc_unused int argc, char *argv[]) success = spl_append_uri(playlist, loader, uri, error); } else { #ifdef ENABLE_DATABASE - success = search_add_to_playlist(uri, playlist, nullptr, + const Database *db = GetDatabase(error); + if (db == nullptr) + return print_error(client, error); + + success = search_add_to_playlist(*db, uri, playlist, nullptr, error); #else success = false; -- cgit v1.2.3