Playlist: pass Database to DatabaseModified()
Don't use global variable.
This commit is contained in:
parent
1769ae54e4
commit
8cf4fb53aa
|
@ -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
|
||||||
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 @@
|
||||||
#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 {
|
||||||
* 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 @@
|
||||||
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:
|
||||||
/**
|
/**
|
||||||
* 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 @@
|
||||||
|
|
||||||
#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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue