Commit 8cf4fb53 authored by Max Kellermann's avatar Max Kellermann

Playlist: pass Database to DatabaseModified()

Don't use global variable.
parent 1769ae54
......@@ -22,6 +22,7 @@
#include "Partition.hxx"
#include "Idle.hxx"
#include "Stats.hxx"
#include "db/DatabaseGlue.hxx"
#ifdef ENABLE_DATABASE
......@@ -35,7 +36,7 @@ void
Instance::DatabaseModified()
{
stats_invalidate();
partition->DatabaseModified();
partition->DatabaseModified(*GetDatabase());
idle_add(IDLE_DATABASE);
}
......
......@@ -25,9 +25,9 @@
#ifdef ENABLE_DATABASE
void
Partition::DatabaseModified()
Partition::DatabaseModified(const Database &db)
{
playlist.DatabaseModified();
playlist.DatabaseModified(db);
}
#endif
......
......@@ -178,7 +178,7 @@ struct Partition {
* The database has been modified. Propagate the change to
* all subsystems.
*/
void DatabaseModified();
void DatabaseModified(const Database &db);
#endif
/**
......
......@@ -26,6 +26,7 @@
enum TagType : uint8_t;
struct PlayerControl;
class DetachedSong;
class Database;
class Error;
struct playlist {
......@@ -141,7 +142,7 @@ public:
/**
* The database has been modified. Pull all updates.
*/
void DatabaseModified();
void DatabaseModified(const Database &db);
#endif
PlaylistResult AppendSong(PlayerControl &pc,
......
......@@ -19,7 +19,6 @@
#include "config.h"
#include "Playlist.hxx"
#include "db/DatabaseGlue.hxx"
#include "db/DatabasePlugin.hxx"
#include "db/LightSong.hxx"
#include "DetachedSong.hxx"
......@@ -56,17 +55,12 @@ UpdatePlaylistSong(const Database &db, DetachedSong &song)
}
void
playlist::DatabaseModified()
playlist::DatabaseModified(const Database &db)
{
const Database *db = GetDatabase();
if (db == nullptr)
/* how can this ever happen? */
return;
bool modified = false;
for (unsigned i = 0, n = queue.GetLength(); i != n; ++i) {
if (UpdatePlaylistSong(*db, queue.Get(i))) {
if (UpdatePlaylistSong(db, queue.Get(i))) {
queue.ModifyAtPosition(i);
modified = true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment