summaryrefslogtreecommitdiff
path: root/src/Main.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-02-20 20:48:20 +0100
committerMax Kellermann <max@musicpd.org>2019-02-20 20:48:20 +0100
commit8b5c33cecdb1e41b08d8141222f6dba50a836889 (patch)
treea9c1835c7b187947598ded40ee1e0cc3ec909d7f /src/Main.cxx
parent6c28adbcd2e0e9b78d7d68193f435e80548565fe (diff)
Instance: use std::unique_ptr<> to manage the Database pointer
Diffstat (limited to 'src/Main.cxx')
-rw-r--r--src/Main.cxx7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 89b6eaf8f..87bda1734 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -188,7 +188,7 @@ glue_db_init_and_load(const ConfigData &config)
instance->database =
CreateConfiguredDatabase(config, instance->event_loop,
instance->io_thread.GetEventLoop(),
- *instance).release();
+ *instance);
if (instance->database == nullptr)
return true;
@@ -196,8 +196,7 @@ glue_db_init_and_load(const ConfigData &config)
InitStorage(config, instance->io_thread.GetEventLoop());
if (instance->storage == nullptr) {
- delete instance->database;
- instance->database = nullptr;
+ instance->database.reset();
LogDefault(config_domain,
"Found database setting without "
"music_directory - disabling database");
@@ -216,7 +215,7 @@ glue_db_init_and_load(const ConfigData &config)
std::throw_with_nested(std::runtime_error("Failed to open database plugin"));
}
- auto *db = dynamic_cast<SimpleDatabase *>(instance->database);
+ auto *db = dynamic_cast<SimpleDatabase *>(instance->database.get());
if (db == nullptr)
return true;