From fd03c5b1ddbd709003e92362cfcfa35a85cd3b9d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Sep 2009 22:35:55 +0200 Subject: [PATCH] screen_play: simplified function playlist_save() --- src/screen_play.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/screen_play.c b/src/screen_play.c index 6872b13..fbabe10 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -311,7 +311,6 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname) filename_utf8 = locale_to_utf8(filename); error = mpdclient_cmd_save_playlist(c, filename_utf8); - g_free(filename_utf8); if (error) { gint code = GET_ACK_ERROR_CODE(error); @@ -326,28 +325,35 @@ playlist_save(struct mpdclient *c, char *name, char *defaultname) buf)); g_free(buf); - if (key == YES[0]) { - filename_utf8 = locale_to_utf8(filename); - error = mpdclient_cmd_delete_playlist(c, filename_utf8); + if (key != YES[0]) { g_free(filename_utf8); + g_free(filename); + screen_status_printf(_("Aborted")); + return -1; + } - if (error) { - g_free(filename); - return -1; - } + error = mpdclient_cmd_delete_playlist(c, filename_utf8); + if (error) { + g_free(filename_utf8); + g_free(filename); + return -1; + } - error = playlist_save(c, filename, NULL); + error = mpdclient_cmd_save_playlist(c, filename_utf8); + if (error) { + g_free(filename_utf8); g_free(filename); return error; } - - screen_status_printf(_("Aborted")); + } else { + g_free(filename_utf8); + g_free(filename); + return -1; } - - g_free(filename); - return -1; } + g_free(filename_utf8); + /* success */ screen_status_printf(_("Saved %s"), filename); g_free(filename); -- 2.30.2