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 @@ ...@@ -22,6 +22,7 @@
#include "Partition.hxx" #include "Partition.hxx"
#include "Idle.hxx" #include "Idle.hxx"
#include "Stats.hxx" #include "Stats.hxx"
#include "db/DatabaseGlue.hxx"
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
...@@ -35,7 +36,7 @@ void ...@@ -35,7 +36,7 @@ void
Instance::DatabaseModified() Instance::DatabaseModified()
{ {
stats_invalidate(); stats_invalidate();
partition->DatabaseModified(); partition->DatabaseModified(*GetDatabase());
idle_add(IDLE_DATABASE); idle_add(IDLE_DATABASE);
} }
......
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
void void
Partition::DatabaseModified() Partition::DatabaseModified(const Database &db)
{ {
playlist.DatabaseModified(); playlist.DatabaseModified(db);
} }
#endif #endif
......
...@@ -178,7 +178,7 @@ struct Partition { ...@@ -178,7 +178,7 @@ struct Partition {
* The database has been modified. Propagate the change to * The database has been modified. Propagate the change to
* all subsystems. * all subsystems.
*/ */
void DatabaseModified(); void DatabaseModified(const Database &db);
#endif #endif
/** /**
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
enum TagType : uint8_t; enum TagType : uint8_t;
struct PlayerControl; struct PlayerControl;
class DetachedSong; class DetachedSong;
class Database;
class Error; class Error;
struct playlist { struct playlist {
...@@ -141,7 +142,7 @@ public: ...@@ -141,7 +142,7 @@ public:
/** /**
* The database has been modified. Pull all updates. * The database has been modified. Pull all updates.
*/ */
void DatabaseModified(); void DatabaseModified(const Database &db);
#endif #endif
PlaylistResult AppendSong(PlayerControl &pc, PlaylistResult AppendSong(PlayerControl &pc,
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "config.h" #include "config.h"
#include "Playlist.hxx" #include "Playlist.hxx"
#include "db/DatabaseGlue.hxx"
#include "db/DatabasePlugin.hxx" #include "db/DatabasePlugin.hxx"
#include "db/LightSong.hxx" #include "db/LightSong.hxx"
#include "DetachedSong.hxx" #include "DetachedSong.hxx"
...@@ -56,17 +55,12 @@ UpdatePlaylistSong(const Database &db, DetachedSong &song) ...@@ -56,17 +55,12 @@ UpdatePlaylistSong(const Database &db, DetachedSong &song)
} }
void void
playlist::DatabaseModified() playlist::DatabaseModified(const Database &db)
{ {
const Database *db = GetDatabase();
if (db == nullptr)
/* how can this ever happen? */
return;
bool modified = false; bool modified = false;
for (unsigned i = 0, n = queue.GetLength(); i != n; ++i) { 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); queue.ModifyAtPosition(i);
modified = true; 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