From 92fb0e829a9b61d1b1db4bdbe6096c1772b7c819 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 14 Jan 2013 11:00:22 +0100 Subject: StateFile: convert to a class --- src/Main.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/Main.cxx') diff --git a/src/Main.cxx b/src/Main.cxx index f9062ccc..e0083bff 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -101,6 +101,8 @@ EventLoop *main_loop; Partition *global_partition; +static StateFile *state_file; + static bool glue_daemonize_init(const struct options *options, GError **error_r) { @@ -225,14 +227,18 @@ glue_state_file_init(GError **error_r) GError *error = NULL; char *path = config_dup_path(CONF_STATE_FILE, &error); - if (path == NULL && error != NULL) { - g_propagate_error(error_r, error); - return false; + if (path == nullptr) { + if (error != nullptr) { + g_propagate_error(error_r, error); + return false; + } + + return true; } - state_file_init(path, *global_partition); + state_file = new StateFile(path, *global_partition, *main_loop); g_free(path); - + state_file->Read(); return true; } @@ -519,7 +525,11 @@ int mpd_main(int argc, char *argv[]) mpd_inotify_finish(); #endif - state_file_finish(*global_partition); + if (state_file != nullptr) { + state_file->Write(); + delete state_file; + } + pc_kill(&global_partition->pc); finishZeroconf(); client_manager_deinit(); -- cgit v1.2.3