aboutsummaryrefslogtreecommitdiffstats
path: root/src/Main.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-01 00:26:34 +0100
committerMax Kellermann <max@duempel.org>2014-02-04 11:22:33 +0100
commitcf6281a5a758e4b93d67f7fd5804a8cff60ddbf9 (patch)
tree7368011b1ecf5ae6db6dcafb676fddf03ff9d823 /src/Main.cxx
parentf00710a57e80738c33255eaa1347ab776fbce869 (diff)
downloadmpd-cf6281a5a758e4b93d67f7fd5804a8cff60ddbf9.tar.gz
mpd-cf6281a5a758e4b93d67f7fd5804a8cff60ddbf9.tar.xz
mpd-cf6281a5a758e4b93d67f7fd5804a8cff60ddbf9.zip
Instance: add Database attribute
Move from db/DatabaseGlue.cxx, eliminating global variable.
Diffstat (limited to 'src/Main.cxx')
-rw-r--r--src/Main.cxx18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index d7d13e2b3..8a5ed7506 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -195,22 +195,26 @@ glue_db_init_and_load(void)
if (param == nullptr)
return true;
+ bool is_simple;
Error error;
- if (!DatabaseGlobalInit(*main_loop, *instance, *param, error))
+ instance->database = DatabaseGlobalInit(*main_loop, *instance, *param,
+ is_simple, error);
+ if (instance->database == nullptr)
FatalError(error);
delete allocated;
- if (!DatabaseGlobalOpen(error))
+ if (!instance->database->Open(error))
FatalError(error);
- if (!db_is_simple())
+ if (!is_simple)
return true;
- instance->update = new UpdateService(*main_loop, db_get_simple());
+ SimpleDatabase &db = *(SimpleDatabase *)instance->database;
+ instance->update = new UpdateService(*main_loop, db);
/* run database update after daemonization? */
- return db_exists();
+ return db.FileExists();
}
#endif
@@ -577,8 +581,8 @@ int mpd_main(int argc, char *argv[])
#ifdef ENABLE_DATABASE
delete instance->update;
-
- DatabaseGlobalDeinit();
+ instance->database->Close();
+ delete instance->database;
#endif
#ifdef ENABLE_SQLITE