summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Main.cxx4
-rw-r--r--src/playlist/PlaylistRegistry.hxx11
-rw-r--r--test/dump_playlist.cxx4
3 files changed, 13 insertions, 6 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 86fc9b09a..e5046a7ad 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -550,7 +550,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
client_manager_init(raw_config);
const ScopeInputPluginsInit input_plugins_init(raw_config,
instance->io_thread.GetEventLoop());
- playlist_list_global_init(raw_config);
+ const ScopePlaylistPluginsInit playlist_plugins_init(raw_config);
#ifdef ENABLE_DAEMON
daemonize_commit();
@@ -654,8 +654,6 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
sticker_global_finish();
#endif
- playlist_list_global_finish();
-
return EXIT_SUCCESS;
}
diff --git a/src/playlist/PlaylistRegistry.hxx b/src/playlist/PlaylistRegistry.hxx
index 210015d50..7cd6fb348 100644
--- a/src/playlist/PlaylistRegistry.hxx
+++ b/src/playlist/PlaylistRegistry.hxx
@@ -47,6 +47,17 @@ playlist_list_global_init(const ConfigData &config);
void
playlist_list_global_finish() noexcept;
+class ScopePlaylistPluginsInit {
+public:
+ explicit ScopePlaylistPluginsInit(const ConfigData &config) {
+ playlist_list_global_init(config);
+ }
+
+ ~ScopePlaylistPluginsInit() noexcept {
+ playlist_list_global_finish();
+ }
+};
+
/**
* Opens a playlist by its URI.
*/
diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx
index 111fbc47f..c4aea7de8 100644
--- a/test/dump_playlist.cxx
+++ b/test/dump_playlist.cxx
@@ -65,7 +65,7 @@ try {
io_thread.Start();
const ScopeInputPluginsInit input_plugins_init(config, io_thread.GetEventLoop());
- playlist_list_global_init(config);
+ const ScopePlaylistPluginsInit playlist_plugins_init(config);
const ScopeDecoderPluginsInit decoder_plugins_init(config);
/* open the playlist */
@@ -116,8 +116,6 @@ try {
playlist.reset();
is.reset();
- playlist_list_global_finish();
-
return EXIT_SUCCESS;
} catch (...) {
PrintException(std::current_exception());