[sound-juicer] Cleanup metadata_cb()
- From: Phillip Wood <pwood src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer] Cleanup metadata_cb()
- Date: Mon, 17 Aug 2015 13:09:28 +0000 (UTC)
commit 9daeab5262d3988a1301a52585dd310d151ef541
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Mon Aug 10 19:04:00 2015 +0100
Cleanup metadata_cb()
Use g_clear_pointer() where we can and try to make the logic clearer.
https://bugzilla.gnome.org/show_bug.cgi?id=753508
src/sj-main.c | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/src/sj-main.c b/src/sj-main.c
index 899bfdd..4769b8c 100644
--- a/src/sj-main.c
+++ b/src/sj-main.c
@@ -1162,25 +1162,21 @@ metadata_cb (SjMetadataGetter *m, GList *albums, GError *error)
set_action_enabled ("re-read", TRUE);
/* Free old album details */
- if (current_album != NULL) {
- album_details_free (current_album);
- current_album = NULL;
- }
+ g_clear_pointer (¤t_album, (GDestroyNotify) album_details_free);
/* Set the new current album pointer */
- if (albums == NULL) {
- current_album = NULL;
- } else if (g_list_next (albums)) {
- current_album = multiple_album_dialog (albums);
- /* Concentrate here. We remove the album we want from the list, and then
- deep-free the list. */
- albums = g_list_remove (albums, current_album);
- g_list_free_full (albums, (GDestroyNotify)album_details_free);
- albums = NULL;
- } else {
- current_album = albums->data;
- /* current_album now owns ->data, so just free the list */
- g_list_free (albums);
- albums = NULL;
+ if (albums != NULL) {
+ if (albums->next != NULL) {
+ current_album = multiple_album_dialog (albums);
+ /* Concentrate here. We remove the album we want from the list, and then
+ deep-free the list. */
+ albums = g_list_remove (albums, current_album);
+ g_list_free_full (albums, (GDestroyNotify)album_details_free);
+ albums = NULL;
+ } else {
+ current_album = albums->data;
+ /* current_album now owns ->data, so just free the list */
+ g_clear_pointer (&albums, (GDestroyNotify) g_list_free);
+ }
}
update_ui_for_album (current_album);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]