summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-01-20 13:25:19 +0100
committerMax Kellermann <max@musicpd.org>2020-01-20 13:25:19 +0100
commit5d597a3646ccc91899641e586daa7c290d845c5f (patch)
treea21825da4664ab116419c35b83b6f5222b032b4f
parent56eaf000a477c609e05504e613dacbe829fbe641 (diff)
Instance: manage StateFile with std::unique_ptr
-rw-r--r--src/Instance.cxx1
-rw-r--r--src/Instance.hxx2
-rw-r--r--src/Main.cxx11
3 files changed, 5 insertions, 9 deletions
diff --git a/src/Instance.cxx b/src/Instance.cxx
index 4daf10d16..e0ae30dfe 100644
--- a/src/Instance.cxx
+++ b/src/Instance.cxx
@@ -21,6 +21,7 @@
#include "Instance.hxx"
#include "Partition.hxx"
#include "IdleFlags.hxx"
+#include "StateFile.hxx"
#include "Stats.hxx"
#include "client/List.hxx"
#include "input/cache/Manager.hxx"
diff --git a/src/Instance.hxx b/src/Instance.hxx
index 5a679b23f..6d63efdaa 100644
--- a/src/Instance.hxx
+++ b/src/Instance.hxx
@@ -127,7 +127,7 @@ struct Instance final
std::list<Partition> partitions;
- StateFile *state_file = nullptr;
+ std::unique_ptr<StateFile> state_file;
#ifdef ENABLE_SQLITE
std::unique_ptr<StickerDatabase> sticker_database;
diff --git a/src/Main.cxx b/src/Main.cxx
index d98e279fe..5b3b5b740 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -262,9 +262,9 @@ glue_state_file_init(Instance &instance, const ConfigData &raw_config)
if (!config.IsEnabled())
return;
- instance.state_file = new StateFile(std::move(config),
- instance.partitions.front(),
- instance.event_loop);
+ instance.state_file = std::make_unique< StateFile>(std::move(config),
+ instance.partitions.front(),
+ instance.event_loop);
instance.state_file->Read();
}
@@ -552,11 +552,6 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
instance.BeginShutdownUpdate();
- if (instance.state_file != nullptr) {
- instance.state_file->Write();
- delete instance.state_file;
- }
-
ZeroconfDeinit();
instance.BeginShutdownPartitions();