[easytag/wip/musicbrainz-support-merge: 44/48] Fixed Memory Leaks due to error in between of search operation and some code improvements



commit 992be883ae4133b1be7407bf8bda9a6d970a3f6b
Author: Abhinav <abhijangda hotmail com>
Date:   Thu Jul 31 23:56:43 2014 +0530

    Fixed Memory Leaks due to error in between of search operation and some code improvements

 src/mb_search.c          |  429 ++++++++++++++++++++++++++++++++++------------
 src/mbentityview.c       |   72 ++-------
 src/musicbrainz_dialog.c |  170 ++++++++++++-------
 3 files changed, 441 insertions(+), 230 deletions(-)
---
diff --git a/src/mb_search.c b/src/mb_search.c
index 092bbf0..20e5149 100755
--- a/src/mb_search.c
+++ b/src/mb_search.c
@@ -27,6 +27,9 @@
 #include "mb_search.h"
 #include "musicbrainz_dialog.h"
 
+/****************
+ * Declarations *
+ ****************/
 static gchar *server = NULL;
 static int port = 0;
 
@@ -37,9 +40,22 @@ static int port = 0;
                                                         ET_MB5_SEARCH_ERROR_CANCELLED,\
                                                         _("Operation cancelled by user"));\
                                            g_assert (error == NULL || *error != NULL);\
-                                           return FALSE;\
+                                           goto cancel;\
                                       }
 
+/**************
+ * Prototypes *
+ **************/
+static void
+et_musicbrainz_set_error_from_query (Mb5Query query, tQueryResult result, 
+                                     GError **error);
+static void
+free_mb_node_children (GNode *node);
+
+/*************
+ * Functions *
+ *************/
+
 /*
  * et_mb5_search_error_quark:
  *
@@ -184,15 +200,16 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
 {
     Mb5Query query;
     Mb5Metadata metadata;
-    char error_message[256];
+    Mb5Metadata metadata_entity;
     tQueryResult result;
     char *param_values[1];
     char *param_names[1];
 
-    CHECK_CANCELLED(cancellable);
-
     param_names[0] = "inc";
     query = mb5_query_new (USER_AGENT, server, port);
+    metadata = NULL;
+    metadata_entity = NULL;
+    CHECK_CANCELLED(cancellable);
 
     if (child_type == MB_ENTITY_KIND_ALBUM &&
         parent_type == MB_ENTITY_KIND_ARTIST)
@@ -231,7 +248,6 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
 
                     if (release)
                     {
-                        Mb5Metadata metadata_release;
                         gchar buf[NAME_MAX_SIZE];
                         GNode *node;
                         EtMbEntity *entity;
@@ -253,18 +269,31 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
                                                    buf,
                                                    sizeof (buf));
                         buf[size] = '\0';
-                        metadata_release = mb5_query_query (query, "release",
-                                                            buf, "",
-                                                            1, param_names,
-                                                            param_values);
-                        CHECK_CANCELLED(cancellable);
-                        entity = g_slice_new (EtMbEntity);
-                        entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
-                        entity->type = MB_ENTITY_KIND_ALBUM;
-                        entity->is_red_line = FALSE;
-                        node = g_node_new (entity);
-                        g_node_append (root, node);
-                        mb5_metadata_delete (metadata_release);
+                        metadata_entity = mb5_query_query (query, "release",
+                                                           buf, "",
+                                                           1, param_names,
+                                                           param_values);
+                        result = mb5_query_get_lastresult (query);
+
+                        if (result == eQuery_Success)
+                        {
+                            if (metadata_entity)
+                            {
+                                CHECK_CANCELLED(cancellable);
+                                entity = g_slice_new (EtMbEntity);
+                                entity->entity = mb5_release_clone (mb5_metadata_get_release 
(metadata_entity));
+                                entity->type = MB_ENTITY_KIND_ALBUM;
+                                entity->is_red_line = FALSE;
+                                node = g_node_new (entity);
+                                g_node_append (root, node);
+                                mb5_metadata_delete (metadata_entity);
+                            }
+                        }
+                        else
+                        {
+                            free_mb_node_children (root);
+                            goto err;
+                        }
                     }
                 }
             }
@@ -304,7 +333,6 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
 
                     if (medium)
                     {
-                        Mb5Metadata metadata_recording;
                         gchar buf[NAME_MAX_SIZE];
                         GNode *node;
                         EtMbEntity *entity;
@@ -327,17 +355,8 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
                         {
                             Mb5Recording recording;
 
-                            if (g_cancellable_is_cancelled (cancellable))
-                            {
-                                g_set_error (error, ET_MB5_SEARCH_ERROR,
-                                             ET_MB5_SEARCH_ERROR_CANCELLED,
-                                             _("Operation cancelled by user"));
-                                mb5_query_delete (query);
-                                mb5_metadata_delete (metadata);
-                                g_assert (error == NULL || *error != NULL);
-                                return FALSE;
-                            }
 
+                            CHECK_CANCELLED(cancellable);
                             recording = mb5_track_get_recording (mb5_track_list_item (track_list, j));
                             size = mb5_recording_get_title (recording, buf,
                                                             sizeof (buf));
@@ -354,19 +373,32 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
                                                          buf,
                                                          sizeof (buf));
                             CHECK_CANCELLED(cancellable);
-                            metadata_recording = mb5_query_query (query,
-                                                                  "recording",
-                                                                  buf, "", 1,
-                                                                  param_names,
-                                                                  param_values);
-                            CHECK_CANCELLED(cancellable);
-                            entity = g_slice_new (EtMbEntity);
-                            entity->entity = mb5_recording_clone (mb5_metadata_get_recording 
(metadata_recording));
-                            entity->type = MB_ENTITY_KIND_TRACK;
-                            entity->is_red_line = FALSE;
-                            node = g_node_new (entity);
-                            g_node_append (root, node);
-                            mb5_metadata_delete (metadata_recording);
+                            metadata_entity = mb5_query_query (query,
+                                                               "recording",
+                                                               buf, "", 1,
+                                                               param_names,
+                                                               param_values);
+                            result = mb5_query_get_lastresult (query);
+
+                            if (result == eQuery_Success)
+                            {
+                                if (metadata_entity)
+                                {
+                                    CHECK_CANCELLED(cancellable);
+                                    entity = g_slice_new (EtMbEntity);
+                                    entity->entity = mb5_recording_clone (mb5_metadata_get_recording 
(metadata_entity));
+                                    entity->type = MB_ENTITY_KIND_TRACK;
+                                    entity->is_red_line = FALSE;
+                                    node = g_node_new (entity);
+                                    g_node_append (root, node);
+                                    mb5_metadata_delete (metadata_entity);
+                                }
+                            }
+                            else
+                            {
+                                free_mb_node_children (root);
+                                goto err;
+                            }
                         }
                     }
                 }
@@ -382,6 +414,8 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
     else if (child_type == MB_ENTITY_KIND_ALBUM &&
              parent_type == MB_ENTITY_KIND_FREEDBID)
     {
+        mb5_query_delete (query);
+
         return et_musicbrainz_search (parent_mbid, child_type, root, error,
                                       cancellable);
     }
@@ -392,50 +426,44 @@ et_musicbrainz_search_in_entity (MbEntityKind child_type,
     return TRUE;
 
     err:
-    mb5_query_get_lasterrormessage (query, error_message,
-                                    sizeof(error_message));
+    
+    if (metadata_entity)
+    {
+        mb5_metadata_delete (metadata_entity);
+    }
 
-    switch (result)
+    if (metadata)
     {
-        case eQuery_ConnectionError:
-            g_set_error (error, ET_MB5_SEARCH_ERROR,
-                         ET_MB5_SEARCH_ERROR_CONNECTION, error_message);
-            break;
+        mb5_metadata_delete (metadata);
+    }
 
-        case eQuery_Timeout:
-            g_set_error (error, ET_MB5_SEARCH_ERROR,
-                         ET_MB5_SEARCH_ERROR_TIMEOUT, error_message);
-            break;
+    et_musicbrainz_set_error_from_query (query, result, error);
+    mb5_query_delete (query);
+    g_assert (error == NULL || *error != NULL);
+    
+    return FALSE;
 
-        case eQuery_AuthenticationError:
-            g_set_error (error, ET_MB5_SEARCH_ERROR,
-                         ET_MB5_SEARCH_ERROR_AUTHENTICATION, error_message);
-            break;
+    cancel:
 
-        case eQuery_FetchError:
-            g_set_error (error, ET_MB5_SEARCH_ERROR,
-                         ET_MB5_SEARCH_ERROR_FETCH, error_message);
-            break;
- 
-        case eQuery_RequestError:
-            g_set_error (error, ET_MB5_SEARCH_ERROR,
-                         ET_MB5_SEARCH_ERROR_REQUEST, error_message);
-            break;
- 
-        case eQuery_ResourceNotFound:
-            g_set_error (error, ET_MB5_SEARCH_ERROR,
-                         ET_MB5_SEARCH_ERROR_RESOURCE_NOT_FOUND,
-                         error_message);
-            break;
-
-        default:
-            break;
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
     }
 
+    mb5_query_delete (query);
     g_assert (error == NULL || *error != NULL);
+
     return FALSE;
 }
 
+/*
+ * et_musicbrainz_set_error_from_query:
+ * @query: Query
+ * @result: Result of the Query
+ * @error: GError to set
+ *
+ * Sets GError on the basis of tQueryResult.
+ */
 static void
 et_musicbrainz_set_error_from_query (Mb5Query query, tQueryResult result, 
                                      GError **error)
@@ -486,6 +514,33 @@ et_musicbrainz_set_error_from_query (Mb5Query query, tQueryResult result,
     g_assert (error == NULL || *error != NULL);
 }
 
+static void
+free_mb_node_children (GNode *node)
+{
+    GNode *child;
+
+    child = g_node_first_child (node);
+
+    while (child)
+    {
+        GNode *child1;
+        child1 = g_node_next_sibling (child);
+        free_mb_tree (&child);
+        child = child1;
+    }
+}
+
+/*
+ * et_musicbrainz_search_artist:
+ * @string: String to search
+ * @root: Root Node
+ * @error: GErorr
+ * @cancellable: GCancellable
+ *
+ * Returns: TRUE if successfull otherwise FALSE
+ *
+ * Search for Artists with name as @string
+ */
 static gboolean
 et_musicbrainz_search_artist (gchar *string, GNode *root, GError **error,
                               GCancellable *cancellable)
@@ -501,8 +556,8 @@ et_musicbrainz_search_artist (gchar *string, GNode *root, GError **error,
     param_names[0] = "query";
     param_names[1] = "limit";
     param_values[1] = SEARCH_LIMIT_STR;
-    CHECK_CANCELLED(cancellable);
     query = mb5_query_new (USER_AGENT, server, port);
+    CHECK_CANCELLED(cancellable);
     param_values[0] = g_strconcat ("artist:", string, NULL);
     metadata = mb5_query_query (query, "artist", "", "", 2, param_names,
                                 param_values);
@@ -545,8 +600,8 @@ et_musicbrainz_search_artist (gchar *string, GNode *root, GError **error,
         goto err;
     }
 
-    mb5_query_delete (query);
     CHECK_CANCELLED(cancellable);
+    mb5_query_delete (query);
 
     return TRUE;
 
@@ -556,26 +611,46 @@ et_musicbrainz_search_artist (gchar *string, GNode *root, GError **error,
     g_assert (error == NULL || *error != NULL);
 
     return FALSE;
+    
+    cancel:
+    mb5_query_delete (query);
+    g_assert (error == NULL || *error != NULL);
+
+    return FALSE;
 }
 
+/*
+ * et_musicbrainz_search_album:
+ * @string: String to search
+ * @root: Root Node
+ * @error: GErorr
+ * @cancellable: GCancellable
+ *
+ * Returns: TRUE if successfull otherwise FALSE
+ *
+ * Search for Albums with name as @string
+ */
 static gboolean
 et_musicbrainz_search_album (gchar *string, GNode *root, GError **error,
                              GCancellable *cancellable)
 {
     Mb5Query query;
     Mb5Metadata metadata;
+    Mb5Metadata metadata_release;
     tQueryResult result;
     char *param_values[2];
     char *param_names[2];
 
     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+    metadata = NULL;
+    metadata_release = NULL;
     param_names[0] = "query";
     param_names[1] = "limit";
     param_values[1] = SEARCH_LIMIT_STR;
-    CHECK_CANCELLED(cancellable);
     query = mb5_query_new (USER_AGENT, server, port);
     param_values[0] = g_strconcat ("release:", string, NULL);
+    CHECK_CANCELLED(cancellable);
     metadata = mb5_query_query (query, "release", "", "", 2, param_names,
                                 param_values);
     result = mb5_query_get_lastresult (query);
@@ -610,7 +685,6 @@ et_musicbrainz_search_album (gchar *string, GNode *root, GError **error,
 
                 if (release)
                 {
-                    Mb5Metadata metadata_release;
                     gchar buf[NAME_MAX_SIZE];
                     GNode *node;
                     EtMbEntity *entity;
@@ -635,14 +709,26 @@ et_musicbrainz_search_album (gchar *string, GNode *root, GError **error,
                                                         buf, "",
                                                         1, param_names,
                                                         param_values);
-                    CHECK_CANCELLED(cancellable);
-                    entity = g_slice_new (EtMbEntity);
-                    entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
-                    entity->type = MB_ENTITY_KIND_ALBUM;
-                    entity->is_red_line = FALSE;
-                    node = g_node_new (entity);
-                    g_node_append (root, node);
-                    mb5_metadata_delete (metadata_release);
+                    result = mb5_query_get_lastresult (query);
+
+                    if (result == eQuery_Success)
+                    {
+                        if (metadata_release)
+                        {
+                            CHECK_CANCELLED(cancellable);
+                            entity = g_slice_new (EtMbEntity);
+                            entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
+                            entity->type = MB_ENTITY_KIND_ALBUM;
+                            entity->is_red_line = FALSE;
+                            node = g_node_new (entity);
+                            g_node_append (root, node);
+                            mb5_metadata_delete (metadata_release);
+                        }
+                    }
+                    else
+                    {
+                        goto err;
+                    }
                 }
             }
         }
@@ -654,37 +740,74 @@ et_musicbrainz_search_album (gchar *string, GNode *root, GError **error,
         goto err;
     }
 
-    mb5_query_delete (query);
     CHECK_CANCELLED(cancellable);
+    mb5_query_delete (query);
 
     return TRUE;
 
     err:
+    
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
+    }
+
     et_musicbrainz_set_error_from_query (query, result, error);
     mb5_query_delete (query);
     g_assert (error == NULL || *error != NULL);
 
     return FALSE;
+    
+    cancel:
+    
+    if (metadata_release)
+    {
+        mb5_metadata_delete (metadata_release);
+    }
+
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
+    }
+
+    mb5_query_delete (query);
+    g_assert (error == NULL || *error != NULL);
+
+    return FALSE;
 }
 
+/*
+ * et_musicbrainz_search_track:
+ * @string: String to search
+ * @root: Root Node
+ * @error: GErorr
+ * @cancellable: GCancellable
+ *
+ * Returns: TRUE if successfull otherwise FALSE
+ *
+ * Search for Tracks with name as @string
+ */
 static gboolean
 et_musicbrainz_search_track (gchar *string, GNode *root, GError **error,
                              GCancellable *cancellable)
 {
     Mb5Query query;
     Mb5Metadata metadata;
+    Mb5Metadata metadata_recording;
     tQueryResult result;
     char *param_values[2];
     char *param_names[2];
 
     g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
+    metadata = NULL;
     param_names[0] = "query";
     param_names[1] = "limit";
     param_values[1] = SEARCH_LIMIT_STR;
-    CHECK_CANCELLED(cancellable);
+    metadata_recording = NULL;
     query = mb5_query_new (USER_AGENT, server, port);
     param_values[0] = g_strconcat ("recordings:", string, NULL);
+    CHECK_CANCELLED(cancellable);
     metadata = mb5_query_query (query, "recording", "", "", 2,
                                 param_names, param_values);
     result = mb5_query_get_lastresult (query);
@@ -713,7 +836,6 @@ et_musicbrainz_search_track (gchar *string, GNode *root, GError **error,
             for (i = 0; i < mb5_recording_list_size (list); i++)
             {
                 Mb5Recording recording;
-                Mb5Metadata metadata_recording;
                 gchar buf[NAME_MAX_SIZE];
                 GNode *node;
                 EtMbEntity *entity;
@@ -738,14 +860,26 @@ et_musicbrainz_search_track (gchar *string, GNode *root, GError **error,
                                                       buf, "",
                                                       1, param_names,
                                                       param_values);
-                CHECK_CANCELLED(cancellable);
-                entity = g_slice_new (EtMbEntity);
-                entity->entity = mb5_recording_clone (mb5_metadata_get_recording (metadata_recording));
-                entity->type = MB_ENTITY_KIND_TRACK;
-                entity->is_red_line = FALSE;
-                node = g_node_new (entity);
-                g_node_append (root, node);
-                mb5_metadata_delete (metadata_recording);
+                result = mb5_query_get_lastresult (query);
+
+                if (result == eQuery_Success)
+                {
+                    if (metadata_recording)
+                    {
+                        CHECK_CANCELLED(cancellable);
+                        entity = g_slice_new (EtMbEntity);
+                        entity->entity = mb5_recording_clone (mb5_metadata_get_recording 
(metadata_recording));
+                        entity->type = MB_ENTITY_KIND_TRACK;
+                        entity->is_red_line = FALSE;
+                        node = g_node_new (entity);
+                        g_node_append (root, node);
+                        mb5_metadata_delete (metadata_recording);
+                    }
+                }
+                else
+                {
+                    goto err;
+                }
             }
         }
 
@@ -756,19 +890,53 @@ et_musicbrainz_search_track (gchar *string, GNode *root, GError **error,
         goto err;
     }
 
-    mb5_query_delete (query);
     CHECK_CANCELLED(cancellable);
+    mb5_query_delete (query);
 
     return TRUE;
 
     err:
+
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
+    }
+
     et_musicbrainz_set_error_from_query (query, result, error);
     mb5_query_delete (query);
     g_assert (error == NULL || *error != NULL);
 
     return FALSE;
+    
+    cancel:
+    
+    if (metadata_recording)
+    {
+        mb5_metadata_delete (metadata_recording);
+    }
+
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
+    }
+
+    mb5_query_delete (query);
+    g_assert (error == NULL || *error != NULL);
+
+    return FALSE;
 }
 
+/*
+ * et_musicbrainz_search_discid:
+ * @string: String to search
+ * @root: Root Node
+ * @error: GErorr
+ * @cancellable: GCancellable
+ *
+ * Returns: TRUE if successfull otherwise FALSE
+ *
+ * Search for DiscID with value as @string
+ */
 static gboolean
 et_musicbrainz_search_discid (gchar *string, GNode *root, GError **error,
                               GCancellable *cancellable)
@@ -846,14 +1014,26 @@ et_musicbrainz_search_discid (gchar *string, GNode *root, GError **error,
                                                         buf, "",
                                                         1, param_names,
                                                         param_values);
-                    CHECK_CANCELLED(cancellable);
-                    entity = g_slice_new (EtMbEntity);
-                    entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
-                    entity->type = MB_ENTITY_KIND_ALBUM;
-                    entity->is_red_line = FALSE;
-                    node = g_node_new (entity);
-                    g_node_append (root, node);
-                    mb5_metadata_delete (metadata_release);
+                    result = mb5_query_get_lastresult (query);
+
+                    if (result == eQuery_Success)
+                    {
+                        if (metadata_release)
+                        {
+                            CHECK_CANCELLED(cancellable);
+                            entity = g_slice_new (EtMbEntity);
+                            entity->entity = mb5_release_clone (mb5_metadata_get_release (metadata_release));
+                            entity->type = MB_ENTITY_KIND_ALBUM;
+                            entity->is_red_line = FALSE;
+                            node = g_node_new (entity);
+                            g_node_append (root, node);
+                            mb5_metadata_delete (metadata_release);
+                        }
+                    }
+                    else
+                    {
+                        goto err;
+                    }
                 }
             }
         }
@@ -865,19 +1045,40 @@ et_musicbrainz_search_discid (gchar *string, GNode *root, GError **error,
         goto err;
     }
 
-    mb5_query_delete (query);
     CHECK_CANCELLED(cancellable);
+    mb5_query_delete (query);
 
     return TRUE;
-
+        
     err:
+
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
+    }
+
     et_musicbrainz_set_error_from_query (query, result, error);
     mb5_query_delete (query);
     g_assert (error == NULL || *error != NULL);
 
     return FALSE;
+    
+    cancel:
+    
+    return FALSE;
 }
 
+/*
+ * et_musicbrainz_search_freedbid:
+ * @string: String to search
+ * @root: Root Node
+ * @error: GErorr
+ * @cancellable: GCancellable
+ *
+ * Returns: TRUE if successfull otherwise FALSE
+ *
+ * Search for FreeDBID with name as @string
+ */
 static gboolean
 et_musicbrainz_search_freedbid (gchar *string, GNode *root, GError **error,
                                 GCancellable *cancellable)
@@ -952,17 +1153,27 @@ et_musicbrainz_search_freedbid (gchar *string, GNode *root, GError **error,
         goto err;
     }
 
-    mb5_query_delete (query);
     CHECK_CANCELLED(cancellable);
+    mb5_query_delete (query);
 
     return TRUE;
 
     err:
+
+    if (metadata)
+    {
+        mb5_metadata_delete (metadata);
+    }
+
     et_musicbrainz_set_error_from_query (query, result, error);
     mb5_query_delete (query);
     g_assert (error == NULL || *error != NULL);
 
     return FALSE;
+    
+    cancel:
+    
+    return FALSE;
 }
 
 /*
diff --git a/src/mbentityview.c b/src/mbentityview.c
index 3a67e44..b8078bd 100644
--- a/src/mbentityview.c
+++ b/src/mbentityview.c
@@ -247,8 +247,6 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
 {
     /* Traverse node in GNode and add it to list_store */
     MbEntityKind type;
-    Mb5ArtistCredit artist_credit;
-    Mb5NameCreditList name_list;
     Mb5ReleaseGroup release_group;
     Mb5ReleaseList release_list;
     int i;
@@ -309,37 +307,13 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
             case MB_ENTITY_KIND_ALBUM:
             {
                 gchar group[NAME_MAX_SIZE];
-                GString *gstring;
                 gchar name[NAME_MAX_SIZE];
+                gchar *album_artists;
 
                 release_group = mb5_release_get_releasegroup ((Mb5Release)entity);
                 mb5_releasegroup_get_primarytype (release_group, group,
                                                   sizeof (group));
-                artist_credit = mb5_release_get_artistcredit ((Mb5Release)entity);
-                gstring = g_string_new ("");
-
-                if (artist_credit)
-                {
-                    name_list = mb5_artistcredit_get_namecreditlist (artist_credit);
-
-                    for (i = 0; i < mb5_namecredit_list_size (name_list); i++)
-                    {
-                        Mb5NameCredit name_credit;
-                        Mb5Artist name_credit_artist;
-                        int size;
-                        name_credit = mb5_namecredit_list_item (name_list, i);
-                        name_credit_artist = mb5_namecredit_get_artist (name_credit);
-                        size = mb5_artist_get_name (name_credit_artist, name,
-                                                    sizeof (name));
-                        g_string_append_len (gstring, name, size);
-
-                        if (i + 1 < mb5_namecredit_list_size (name_list))
-                        {
-                            g_string_append_len (gstring, ", ", 2);
-                        }
-                    }
-                }
-
+                album_artists = et_mb5_release_get_artists_names (entity);
                 mb5_release_get_title ((Mb5Release)entity, name,
                                        sizeof (name));
                 
@@ -349,7 +323,7 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
                                                        MB_ALBUM_COLUMNS_NAME, 
                                                        name,
                                                        MB_ALBUM_COLUMNS_ARTIST,
-                                                       gstring->str,
+                                                       album_artists,
                                                        MB_ALBUM_COLUMNS_TYPE,
                                                        group,
                                                        MB_ALBUM_COLUMNS_N,
@@ -360,49 +334,24 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
                     gtk_list_store_insert_with_values (list_store, &iter, -1,
                                         MB_ALBUM_COLUMNS_NAME, name,
                                         MB_ALBUM_COLUMNS_ARTIST,
-                                        gstring->str,
+                                        album_artists,
                                         MB_ALBUM_COLUMNS_TYPE, group,
                                         MB_ALBUM_COLUMNS_N, &black, -1);
                 }
 
-                g_string_free (gstring, TRUE);
+                g_free (album_artists);
 
                 break;
             }
 
             case MB_ENTITY_KIND_TRACK:
             {
-                GString *artists;
                 GString *releases;
                 gchar name[NAME_MAX_SIZE];
                 gchar time[NAME_MAX_SIZE];
+                gchar *artists;
 
-                artist_credit = mb5_recording_get_artistcredit ((Mb5Release)entity);
-                artists = g_string_new ("");
-
-                if (artist_credit)
-                {
-                    name_list = mb5_artistcredit_get_namecreditlist (artist_credit);
-
-                    for (i = 0; i < mb5_namecredit_list_size (name_list); i++)
-                    {
-                        Mb5NameCredit name_credit;
-                        Mb5Artist name_credit_artist;
-                        int size;
-
-                        name_credit = mb5_namecredit_list_item (name_list, i);
-                        name_credit_artist = mb5_namecredit_get_artist (name_credit);
-                        size = mb5_artist_get_name (name_credit_artist, name,
-                                                    sizeof (name));
-                        g_string_append_len (artists, name, size);
-
-                        if (i + 1 < mb5_namecredit_list_size (name_list))
-                        {
-                            g_string_append_len (artists, ", ", 2);
-                        }
-                    }
-                }
-
+                artists = et_mb5_recording_get_artists_names (entity);
                 release_list = mb5_recording_get_releaselist ((Mb5Recording)entity);
                 releases = g_string_new ("");
 
@@ -455,7 +404,7 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
                 gtk_list_store_insert_with_values (list_store, &iter, -1,
                                                    MB_TRACK_COLUMNS_NAME, name,
                                                    MB_TRACK_COLUMNS_ARTIST,
-                                                   artists->str,
+                                                   artists,
                                                    MB_TRACK_COLUMNS_ALBUM,
                                                    releases->str,
                                                    MB_TRACK_COLUMNS_TIME,
@@ -463,7 +412,7 @@ add_iter_to_list_store (GtkListStore *list_store, GNode *node)
                                                    MB_TRACK_COLUMNS_N, 
                                                    &black, -1);
                 g_string_free (releases, TRUE);
-                g_string_free (artists, TRUE);
+                g_free (artists);
 
                 break;
             }
@@ -687,6 +636,8 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
     GList *children;
     GList *active_child;
 
+    thread_data = user_data;
+
     if (res &&
         !g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res)))
     {
@@ -695,7 +646,6 @@ search_in_levels_callback (GObject *source, GAsyncResult *res,
         return;
     }
 
-    thread_data = user_data;
     entity_view = thread_data->entity_view;
     priv = ET_MB_ENTITY_VIEW_GET_PRIVATE (entity_view);
     et_music_brainz_dialog_set_statusbar_message (_("Retrieving Completed"));
diff --git a/src/musicbrainz_dialog.c b/src/musicbrainz_dialog.c
index ae3332d..1a04a08 100755
--- a/src/musicbrainz_dialog.c
+++ b/src/musicbrainz_dialog.c
@@ -167,6 +167,7 @@ struct _EtMusicBrainzDialogPrivate
     GtkWidget *tag_choice_dialog;
     GtkWidget *entityView;
     gboolean exit_on_complete;
+    GtkStatusbar *statusbar;
 };
 
 static GtkWidget *mbDialog;
@@ -335,12 +336,14 @@ et_mb_destroy_search (EtMbSearch **search)
         {
             g_list_free_full (((EtMbSelectedSearch *)(*search))->list_iter,
                               (GDestroyNotify)gtk_tree_iter_free);
-            g_slice_free (EtMbSelectedSearch, (EtMbSelectedSearch *)(*search));
+            g_slice_free (EtMbSelectedSearch,
+                          (EtMbSelectedSearch *)(*search));
             break;
         }
         case ET_MB_SEARCH_TYPE_AUTOMATIC:
         {
-            g_slice_free (EtMbAutomaticSearch, (EtMbAutomaticSearch *)(*search));
+            g_slice_free (EtMbAutomaticSearch,
+                          (EtMbAutomaticSearch *)(*search));
             break;
         }
     }
@@ -413,41 +416,44 @@ manual_search_callback (GObject *source, GAsyncResult *res,
                         gpointer user_data)
 {
     GtkComboBoxText *combo_box;
-    EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialogPrivate *priv;
+    EtMusicBrainzDialog *dlg;
+    GSimpleAsyncResult *simple_async;
+    ManualSearchThreadData *thread_data;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    simple_async = G_SIMPLE_ASYNC_RESULT (res);
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
 
-    if (!g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res)))
+    if (!g_simple_async_result_get_op_res_gboolean (simple_async))
     {
         g_object_unref (res);
         g_slice_free (ManualSearchThreadData, user_data);
         et_music_brainz_dialog_stop_set_sensitive (FALSE);
 
-        if (mb_dialog_priv)
+        if (priv)
         {
-            free_mb_tree (&mb_dialog_priv->mb_tree_root);
-            mb_dialog_priv->mb_tree_root = g_node_new (NULL);
+            free_mb_tree (&priv->mb_tree_root);
+            priv->mb_tree_root = g_node_new (NULL);
         }
 
         return;
     }
 
-    et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
-                                     mb_dialog_priv->mb_tree_root);
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
-                        "statusbar")), 0, _("Searching Completed"));
+    thread_data = (ManualSearchThreadData *)user_data;
+    et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (priv->entityView),
+                                     priv->mb_tree_root);
+    gtk_statusbar_push (priv->statusbar, 0, _("Searching Completed"));
     g_object_unref (res);
     combo_box = GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder,
                                                             "cb_manual_search"));
     gtk_combo_box_text_append_text (combo_box,
                                     gtk_combo_box_text_get_active_text (combo_box));
     et_music_brainz_dialog_stop_set_sensitive (FALSE);
-    mb_dialog_priv->search = ET_MB_SEARCH_TYPE_MANUAL;
-    et_mb_set_search_manual (&mb_dialog_priv->search,
-                             ((ManualSearchThreadData *)user_data)->text_to_search,
-                             mb_dialog_priv->mb_tree_root,
-                             ((ManualSearchThreadData *)user_data)->type);
-    g_slice_free (ManualSearchThreadData, (ManualSearchThreadData *)user_data);
+    priv->search = ET_MB_SEARCH_TYPE_MANUAL;
+    et_mb_set_search_manual (&priv->search, thread_data->text_to_search,
+                             priv->mb_tree_root, thread_data->type);
+    g_slice_free (ManualSearchThreadData, thread_data);
 }
 
 /*
@@ -466,8 +472,10 @@ manual_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
     ManualSearchThreadData *thread_data;
     gchar *status_msg;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     error = NULL;
     g_simple_async_result_set_op_res_gboolean (res, FALSE);
 
@@ -482,7 +490,7 @@ manual_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
         return;
     }
 
-    thread_data = (ManualSearchThreadData *)g_async_result_get_user_data (G_ASYNC_RESULT (res));
+    thread_data = g_async_result_get_user_data (G_ASYNC_RESULT (res));
     status_msg = g_strdup_printf (_("Searching %s"),
                                   thread_data->text_to_search);
     et_show_status_msg_in_idle (status_msg);
@@ -539,8 +547,10 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
     int type;
     ManualSearchThreadData *thread_data;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     cb_manual_search_in = GTK_WIDGET (gtk_builder_get_object (builder,
                                                               "cb_manual_search_in"));
     type = gtk_combo_box_get_active (GTK_COMBO_BOX (cb_manual_search_in));
@@ -563,8 +573,8 @@ btn_manual_find_clicked (GtkWidget *btn, gpointer user_data)
     thread_data->type = type;
     thread_data->text_to_search = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (cb_manual_search));
     mb5_search_cancellable = g_cancellable_new ();
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder,
-                        "statusbar")), 0, _("Starting MusicBrainz Search"));
+    gtk_statusbar_push (mb_dialog_priv->statusbar, 0,
+                        _("Starting MusicBrainz Search"));
     mb_dialog_priv->async_result = g_simple_async_result_new (NULL, 
                                                               manual_search_callback,
                                                               thread_data,
@@ -586,8 +596,10 @@ static void
 tool_btn_toggle_red_lines_clicked (GtkWidget *btn, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_entity_view_toggle_red_lines (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
 }
 
@@ -618,8 +630,10 @@ static void
 tool_btn_down_clicked (GtkWidget *btn, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_entity_view_select_down (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
 }
 
@@ -634,8 +648,10 @@ static void
 tool_btn_invert_selection_clicked (GtkWidget *btn, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_entity_view_invert_selection (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
 }
 
@@ -650,8 +666,10 @@ static void
 tool_btn_select_all_clicked (GtkWidget *btn, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_entity_view_select_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
 }
 
@@ -666,8 +684,10 @@ static void
 tool_btn_unselect_all_clicked (GtkWidget *btn, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_entity_view_unselect_all (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView));
 }
 
@@ -682,8 +702,10 @@ static void
 tool_btn_refresh_clicked (GtkWidget *btn, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
 
     if (!mb_dialog_priv->search)
     {
@@ -757,8 +779,10 @@ static void
 entry_tree_view_search_changed (GtkEditable *editable, gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_entity_view_search_in_results (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
                                          gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder,
                                                                         "entry_tree_view_search"))));
@@ -777,8 +801,10 @@ selected_find_callback (GObject *source, GAsyncResult *res,
                         gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
 
     if (!g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res)))
     {
@@ -793,7 +819,7 @@ selected_find_callback (GObject *source, GAsyncResult *res,
 
     et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
                                      mb_dialog_priv->mb_tree_root);
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+    gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("Searching Completed"));
     g_object_unref (res);
     g_hash_table_destroy (((SelectedFindThreadData *)user_data)->hash_table);
@@ -825,9 +851,11 @@ selected_find_thread_func (GSimpleAsyncResult *res, GObject *obj,
     GList *iter;
     SelectedFindThreadData *thread_data;
     GError *error;
+    EtMusicBrainzDialog *dlg;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     g_simple_async_result_set_op_res_gboolean (res, FALSE);
     error = NULL;
     thread_data = (SelectedFindThreadData *)g_async_result_get_user_data (G_ASYNC_RESULT (res));
@@ -954,14 +982,16 @@ btn_selected_find_clicked (GtkWidget *button, gpointer data)
     GHashTable *hash_table;
     SelectedFindThreadData *thread_data;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     iter_list = NULL;
     l = NULL;
 
     if (!get_selected_iter_list (GTK_TREE_VIEW (BrowserList), &iter_list))
     {
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("No Files Selected"));
         return;
     }
@@ -994,7 +1024,7 @@ btn_selected_find_clicked (GtkWidget *button, gpointer data)
     g_simple_async_result_run_in_thread (mb_dialog_priv->async_result,
                                          selected_find_thread_func, 0,
                                          mb5_search_cancellable);
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+    gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("Starting Selected Files Search"));
     et_music_brainz_dialog_stop_set_sensitive (TRUE);
 }
@@ -1048,8 +1078,10 @@ discid_search_callback (GObject *source, GAsyncResult *res,
                         gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
 
     if (!g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res)))
     {
@@ -1062,7 +1094,7 @@ discid_search_callback (GObject *source, GAsyncResult *res,
 
     et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
                                      mb_dialog_priv->mb_tree_root);
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+    gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("Searching Completed"));
     g_object_unref (res);
     g_free (user_data);
@@ -1090,8 +1122,10 @@ discid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
     DiscId *disc;
     gchar *discid;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     error = NULL;
     disc = discid_new ();
     g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res),
@@ -1150,10 +1184,12 @@ static void
 btn_discid_search_clicked (GtkWidget *button, gpointer data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
-
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    EtMusicBrainzDialog *dlg;
+    
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     mb5_search_cancellable = g_cancellable_new ();
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+    gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("Starting MusicBrainz Search"));
     mb_dialog_priv->async_result = g_simple_async_result_new (NULL,
                                                               discid_search_callback,
@@ -1191,8 +1227,10 @@ freedbid_search_callback (GObject *source, GAsyncResult *res,
                           gpointer user_data)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
 
     if (!g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res)))
     {
@@ -1206,7 +1244,7 @@ freedbid_search_callback (GObject *source, GAsyncResult *res,
 
     et_mb_entity_view_set_tree_root (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
                                      mb_dialog_priv->mb_tree_root);
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+    gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("Searching Completed"));
     g_object_unref (res);
     g_free (user_data);
@@ -1234,8 +1272,10 @@ freedbid_search_thread_func (GSimpleAsyncResult *res, GObject *obj,
     GError *error;
     gchar *freedbid;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     error = NULL;
     g_simple_async_result_set_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (res),
                                                FALSE);
@@ -1287,8 +1327,10 @@ btn_automatic_search_clicked (GtkWidget *btn, gpointer data)
     guint disc_length;
     gchar *cddb_discid;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     total_frames = 150;
     disc_length  = 2;
     iter_list = NULL;
@@ -1327,7 +1369,7 @@ btn_automatic_search_clicked (GtkWidget *btn, gpointer data)
                                            &current_iter))
         {
             /* No row is present, return */
-            gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+            gtk_statusbar_push (mb_dialog_priv->statusbar,
                                 0, _("No file selected"));
             return;
         }
@@ -1346,14 +1388,14 @@ btn_automatic_search_clicked (GtkWidget *btn, gpointer data)
 
     if (count == 0)
     {
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                             0, _("No file selected"));
         return;
     }
 
     else if (count > 99)
     {
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                             0, _("More than 99 files selected. Cannot send the request."));
         return;
     }
@@ -1363,7 +1405,7 @@ btn_automatic_search_clicked (GtkWidget *btn, gpointer data)
         gchar *msg;
         msg = g_strdup_printf (ngettext (_("One file selected"),
                                          _("%d files selected"), count), count);
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                             0, msg);
         g_free (msg);
     }
@@ -1393,7 +1435,7 @@ btn_automatic_search_clicked (GtkWidget *btn, gpointer data)
                                    (disc_length << 8) | num_tracks));
 
     mb5_search_cancellable = g_cancellable_new ();
-    gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+    gtk_statusbar_push (mb_dialog_priv->statusbar,
                         0, _("Starting MusicBrainz Search"));
     mb_dialog_priv->async_result = g_simple_async_result_new (NULL,
                                                               freedbid_search_callback,
@@ -1450,15 +1492,17 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
     GList *list_iter1;
     GList *list_iter2;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     file_iter_list = NULL;
     track_iter_list = NULL;
 
     if (!get_selected_iter_list (GTK_TREE_VIEW (BrowserList),
                                  &file_iter_list))
     {
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                             0, _("No Files Selected"));
         return;
     }
@@ -1466,7 +1510,7 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
     if (!et_mb_entity_view_get_selected_entity_list (ET_MB_ENTITY_VIEW (mb_dialog_priv->entityView),
                                                      &track_iter_list))
     {
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                             0, _("No Track Selected"));
         g_list_free_full (file_iter_list, (GDestroyNotify)gtk_tree_iter_free);
 
@@ -1476,7 +1520,7 @@ btn_apply_changes_clicked (GtkWidget *btn, gpointer data)
     if (((EtMbEntity *)track_iter_list->data)->type !=
         MB_ENTITY_KIND_TRACK)
     {
-        gtk_statusbar_push (GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar")),
+        gtk_statusbar_push (mb_dialog_priv->statusbar,
                             0, _("No Track Selected"));
         g_list_free_full (file_iter_list, (GDestroyNotify)gtk_tree_iter_free);
         g_list_free (track_iter_list);
@@ -1592,8 +1636,10 @@ et_apply_track_tag_to_et_file (Mb5Recording recording, ET_File *et_file)
     GtkTreeSelection *selection;
     GtkWidget *tag_choice_tree_view;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     tag_choice_tree_view = GTK_WIDGET (gtk_builder_get_object (builder, "tag_choice_treeview"));
     release_list = mb5_recording_get_releaselist (recording);
     artist = et_mb5_recording_get_artists_names (recording);
@@ -1893,8 +1939,10 @@ mb5_search_error_callback (GObject *source, GAsyncResult *res,
 {
     GError *dest;
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     dest = NULL;
     g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res),
                                            &dest);
@@ -1921,11 +1969,13 @@ static void
 et_musicbrainz_dialog_finalize (GObject *object)
 {
     EtMusicBrainzDialogPrivate *mb_dialog_priv;
+    EtMusicBrainzDialog *dlg;
 
     g_return_if_fail (object != NULL);
     g_return_if_fail (IS_ET_MUSICBRAINZ_DIALOG(object));
-
-    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (ET_MUSICBRAINZ_DIALOG (mbDialog));
+    
+    dlg = ET_MUSICBRAINZ_DIALOG (mbDialog);
+    mb_dialog_priv = ET_MUSICBRAINZ_DIALOG_GET_PRIVATE (dlg);
     et_mb_destroy_search (&mb_dialog_priv->search);
     gtk_widget_destroy (mb_dialog_priv->tag_choice_dialog);
     G_OBJECT_CLASS (et_musicbrainz_dialog_parent_class)->finalize(object);
@@ -1983,6 +2033,7 @@ et_musicbrainz_dialog_init (EtMusicBrainzDialog *dialog)
     priv->search = NULL;
     priv->exit_on_complete = FALSE;
     priv->entityView = et_mb_entity_view_new ();
+    priv->statusbar = GTK_STATUSBAR (gtk_builder_get_object (builder, "statusbar"));
     box = GTK_WIDGET (gtk_builder_get_object (builder, "mb_box"));
     gtk_window_set_title (GTK_WINDOW (dialog), "MusicBrainz Search");
     gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
@@ -1990,7 +2041,6 @@ et_musicbrainz_dialog_init (EtMusicBrainzDialog *dialog)
     gtk_widget_set_size_request (GTK_WIDGET (dialog), 660, 500);
     gtk_box_pack_start (GTK_BOX (gtk_builder_get_object (builder, "central_box")),
                         priv->entityView, TRUE, TRUE, 2);
-
     et_initialize_tag_choice_dialog (priv);
     cb_search = GTK_WIDGET (gtk_builder_get_object (builder, "cb_manual_search"));
     g_signal_connect (gtk_bin_get_child (GTK_BIN (cb_search)), "activate",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]