diff --git a/src/EditPlaylistPage.cxx b/src/EditPlaylistPage.cxx index 703b049d..5668856d 100644 --- a/src/EditPlaylistPage.cxx +++ b/src/EditPlaylistPage.cxx @@ -273,7 +273,7 @@ EditPlaylistPage::OnCommand(struct mpdclient &c, Command cmd) return HandleDelete(c); case Command::SAVE_PLAYLIST: - //playlist_save(screen, c, nullptr); + //playlist_save(screen, c); // TODO return true; diff --git a/src/FileBrowserPage.cxx b/src/FileBrowserPage.cxx index 57b69b90..24240931 100644 --- a/src/FileBrowserPage.cxx +++ b/src/FileBrowserPage.cxx @@ -209,10 +209,8 @@ FileBrowserPage::HandleSave(struct mpdclient &c) noexcept } } - if(defaultname) - playlist_save(screen, c, Utf8ToLocaleZ{defaultname}.c_str()); - else - playlist_save(screen, c, nullptr); + playlist_save(screen, c, + defaultname != nullptr ? Utf8ToLocale{defaultname}.str() : std::string{}); } void diff --git a/src/QueuePage.cxx b/src/QueuePage.cxx index de5bd08a..8b35e920 100644 --- a/src/QueuePage.cxx +++ b/src/QueuePage.cxx @@ -624,7 +624,7 @@ QueuePage::OnCommand(struct mpdclient &c, Command cmd) } case Command::SAVE_PLAYLIST: - playlist_save(screen, c, nullptr); + playlist_save(screen, c); return true; case Command::ADD: diff --git a/src/save_playlist.cxx b/src/save_playlist.cxx index 81755716..8d97ecb0 100644 --- a/src/save_playlist.cxx +++ b/src/save_playlist.cxx @@ -52,13 +52,12 @@ PlaylistNameCompletion::Post([[maybe_unused]] std::string_view value, #endif + int playlist_save(ScreenManager &screen, struct mpdclient &c, - const char *name) noexcept + std::string filename) noexcept { - std::string filename; - - if (name == nullptr) { + if (filename.empty()) { #ifdef NCMPC_MINI Completion *completion = nullptr; #else @@ -74,8 +73,7 @@ playlist_save(ScreenManager &screen, struct mpdclient &c, completion); if (filename.empty()) return -1; - } else - filename = name; + } /* send save command to mpd */ diff --git a/src/save_playlist.hxx b/src/save_playlist.hxx index ab60bd9b..16d9c90d 100644 --- a/src/save_playlist.hxx +++ b/src/save_playlist.hxx @@ -3,9 +3,11 @@ #pragma once +#include + class ScreenManager; struct mpdclient; int playlist_save(ScreenManager &screen, struct mpdclient &c, - const char *name) noexcept; + std::string name={}) noexcept;