From 10e48f7ec632d5c3bfaf8cd3834e19183935efcb Mon Sep 17 00:00:00 2001
From: Julien Bonjean <julien@bonjean.info>
Date: Wed, 4 Aug 2010 12:38:26 -0400
Subject: [PATCH] [#3376] Cleaned some glib and GTK criticals and warnings

---
 sflphone-client-gnome/src/accountlist.c       |  4 +++-
 sflphone-client-gnome/src/callable_obj.c      |  7 +++++--
 .../src/config/accountconfigdialog.c          | 20 +++++++++++++++++++
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/sflphone-client-gnome/src/accountlist.c b/sflphone-client-gnome/src/accountlist.c
index dee7315bea..d73f3450c9 100644
--- a/sflphone-client-gnome/src/accountlist.c
+++ b/sflphone-client-gnome/src/accountlist.c
@@ -360,7 +360,9 @@ gboolean current_account_has_mailbox (void)
     current = account_list_get_current ();
 
     if (current) {
-        if (g_strcasecmp (g_hash_table_lookup (current->properties, ACCOUNT_MAILBOX), "") != 0)
+        gchar * account_mailbox = g_hash_table_lookup (current->properties, ACCOUNT_MAILBOX);
+
+        if (account_mailbox != NULL && g_strcasecmp (account_mailbox, "") != 0)
             return TRUE;
     }
 
diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c
index fabe9045af..54e0f1226c 100644
--- a/sflphone-client-gnome/src/callable_obj.c
+++ b/sflphone-client-gnome/src/callable_obj.c
@@ -436,11 +436,14 @@ gchar* serialize_history_entry (callable_obj_t *entry)
     // and the timestamps
     timestamp = convert_timestamp_to_gchar (entry->_time_stop);
 
+    gchar* peer_name = (entry->_peer_name == NULL || g_strcasecmp (entry->_peer_name,"") == 0) ? "empty": entry->_peer_name;
+    gchar* account_id = (entry->_accountID == NULL || g_strcasecmp (entry->_accountID,"") == 0) ? "empty": entry->_accountID;
+
     result = g_strconcat (history_state, separator,
                           entry->_peer_number, separator,
-                          g_strcasecmp (entry->_peer_name,"") ==0 ? "empty": entry->_peer_name, separator,
+                          peer_name, separator,
                           timestamp, separator,
-                          g_strcasecmp (entry->_accountID,"") ==0 ? "empty": entry->_accountID,
+                          account_id,
                           NULL);
 
     return result;
diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c
index c907995a70..9deb3ebea4 100644
--- a/sflphone-client-gnome/src/config/accountconfigdialog.c
+++ b/sflphone-client-gnome/src/config/accountconfigdialog.c
@@ -122,6 +122,21 @@ enum {
     COLUMN_CREDENTIAL_COUNT
 };
 
+/*
+ * The same window is used with different configurations
+ * so we need to reset some data to prevent side-effects
+ */
+static void reset()
+{
+    entryAlias = NULL;
+    protocolComboBox = NULL;
+    entryHostname = NULL;
+    entryUsername = NULL;
+    entryPassword = NULL;
+    entryUseragent = NULL;
+    entryMailbox = NULL;
+}
+
 /*
  * Display / Hide the password
  */
@@ -290,6 +305,7 @@ static GtkWidget* create_basic_tab (account_t **a)
         curUsername = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERNAME);
         // curRouteSet = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ROUTE);
         curMailbox = g_hash_table_lookup (currentAccount->properties, ACCOUNT_MAILBOX);
+        curMailbox = curMailbox != NULL ? curMailbox : "";
         curUseragent = g_hash_table_lookup (currentAccount->properties, ACCOUNT_USERAGENT);
     }
 
@@ -1268,6 +1284,10 @@ void show_account_window (account_t * a)
     gint response;
     account_t *currentAccount;
 
+
+    // Firstly we reset
+    reset();
+
     // In case the published address is same than local,
     // we must resolve published address from interface name
     gchar * local_interface;
-- 
GitLab