Instance: manage StateFile with std::unique_ptr
This commit is contained in:
parent
56eaf000a4
commit
5d597a3646
|
@ -21,6 +21,7 @@
|
||||||
#include "Instance.hxx"
|
#include "Instance.hxx"
|
||||||
#include "Partition.hxx"
|
#include "Partition.hxx"
|
||||||
#include "IdleFlags.hxx"
|
#include "IdleFlags.hxx"
|
||||||
|
#include "StateFile.hxx"
|
||||||
#include "Stats.hxx"
|
#include "Stats.hxx"
|
||||||
#include "client/List.hxx"
|
#include "client/List.hxx"
|
||||||
#include "input/cache/Manager.hxx"
|
#include "input/cache/Manager.hxx"
|
||||||
|
|
|
@ -127,7 +127,7 @@ struct Instance final
|
||||||
|
|
||||||
std::list<Partition> partitions;
|
std::list<Partition> partitions;
|
||||||
|
|
||||||
StateFile *state_file = nullptr;
|
std::unique_ptr<StateFile> state_file;
|
||||||
|
|
||||||
#ifdef ENABLE_SQLITE
|
#ifdef ENABLE_SQLITE
|
||||||
std::unique_ptr<StickerDatabase> sticker_database;
|
std::unique_ptr<StickerDatabase> sticker_database;
|
||||||
|
|
11
src/Main.cxx
11
src/Main.cxx
|
@ -262,9 +262,9 @@ glue_state_file_init(Instance &instance, const ConfigData &raw_config)
|
||||||
if (!config.IsEnabled())
|
if (!config.IsEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
instance.state_file = new StateFile(std::move(config),
|
instance.state_file = std::make_unique< StateFile>(std::move(config),
|
||||||
instance.partitions.front(),
|
instance.partitions.front(),
|
||||||
instance.event_loop);
|
instance.event_loop);
|
||||||
instance.state_file->Read();
|
instance.state_file->Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,11 +552,6 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
|
||||||
|
|
||||||
instance.BeginShutdownUpdate();
|
instance.BeginShutdownUpdate();
|
||||||
|
|
||||||
if (instance.state_file != nullptr) {
|
|
||||||
instance.state_file->Write();
|
|
||||||
delete instance.state_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroconfDeinit();
|
ZeroconfDeinit();
|
||||||
|
|
||||||
instance.BeginShutdownPartitions();
|
instance.BeginShutdownPartitions();
|
||||||
|
|
Loading…
Reference in New Issue