Commit 031410c7 authored by Max Kellermann's avatar Max Kellermann

Instance: add StateFile* attribute

parent 710def8e
......@@ -40,6 +40,7 @@ class UpdateService;
class Error;
class ClientList;
struct Partition;
class StateFile;
struct Instance final
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
......@@ -79,6 +80,8 @@ struct Instance final
Partition *partition;
StateFile *state_file;
Instance():global_events(event_loop) {}
/**
......
......@@ -128,8 +128,6 @@ Context *context;
Instance *instance;
static StateFile *state_file;
#ifdef ENABLE_DAEMON
static bool
......@@ -284,10 +282,10 @@ glue_state_file_init(Error &error)
config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
StateFile::DEFAULT_INTERVAL);
state_file = new StateFile(std::move(path_fs), interval,
instance->state_file = new StateFile(std::move(path_fs), interval,
*instance->partition,
instance->event_loop);
state_file->Read();
instance->state_file->Read();
return true;
}
......@@ -380,8 +378,8 @@ idle_event_emitted(void)
instance->client_list->IdleAdd(flags);
if (flags & (IDLE_PLAYLIST|IDLE_PLAYER|IDLE_MIXER|IDLE_OUTPUT) &&
state_file != nullptr)
state_file->CheckModified();
instance->state_file != nullptr)
instance->state_file->CheckModified();
}
#ifndef ANDROID
......@@ -655,9 +653,9 @@ try {
instance->update->CancelAllAsync();
#endif
if (state_file != nullptr) {
state_file->Write();
delete state_file;
if (instance->state_file != nullptr) {
instance->state_file->Write();
delete instance->state_file;
}
instance->partition->pc.Kill();
......
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