[empathy/gnome-2-30] accounts-dialog: avoid leaking the account status message
- From: Rob Bradford <rbradford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy/gnome-2-30] accounts-dialog: avoid leaking the account status message
- Date: Thu, 3 Jun 2010 13:58:21 +0000 (UTC)
commit 2ad941149dcca32730db7c1efc70ef3b188bebb6
Author: Rob Bradford <rob linux intel com>
Date: Thu Jun 3 14:24:21 2010 +0100
accounts-dialog: avoid leaking the account status message
Originally this function mixed const and allocated strings using the same
variable, resulting in leaks. This change refactors the code slightly to
prevent such leaks.
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=620476
src/empathy-accounts-dialog.c | 53 +++++++++++++++++++++++++++++++---------
1 files changed, 41 insertions(+), 12 deletions(-)
---
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index a027778..79c3ad9 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -192,12 +192,22 @@ accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
}
static void
+accounts_dialog_status_infobar_set_message (EmpathyAccountsDialog *dialog,
+ const gchar *message)
+{
+ EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+ gchar *message_markup;
+
+ message_markup = g_markup_printf_escaped ("<i>%s</i>", message);
+ gtk_label_set_markup (GTK_LABEL (priv->label_status), message_markup);
+ g_free (message_markup);
+}
+
+static void
accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
TpAccount *account)
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- const gchar *message;
- gchar *message_markup;
gchar *status_message = NULL;
guint status;
guint reason;
@@ -260,7 +270,8 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
switch (status)
{
case TP_CONNECTION_STATUS_CONNECTING:
- message = _("Connectingâ?¦");
+ accounts_dialog_status_infobar_set_message (dialog,
+ _("Connectingâ?¦"));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_INFO);
@@ -271,14 +282,24 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
case TP_CONNECTION_STATUS_CONNECTED:
if (g_strcmp0 (status_message, "") == 0)
{
+ gchar *message;
+
message = g_strdup_printf ("%s",
empathy_presence_get_default_message (presence));
+
+ accounts_dialog_status_infobar_set_message (dialog, message);
+ g_free (message);
}
else
{
+ gchar *message;
+
message = g_strdup_printf ("%s â?? %s",
empathy_presence_get_default_message (presence),
status_message);
+
+ accounts_dialog_status_infobar_set_message (dialog, message);
+ g_free (message);
}
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_INFO);
@@ -287,31 +308,41 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
gtk_widget_hide (priv->throbber);
break;
case TP_CONNECTION_STATUS_DISCONNECTED:
- message = g_strdup_printf (_("Disconnected â?? %s"),
- empathy_status_reason_get_default_message (reason));
-
if (reason == TP_CONNECTION_STATUS_REASON_REQUESTED)
{
+ gchar *message;
+
message = g_strdup_printf (_("Offline â?? %s"),
empathy_status_reason_get_default_message (reason));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_WARNING);
+
+ accounts_dialog_status_infobar_set_message (dialog, message);
+ g_free (message);
}
else
{
+ gchar *message;
+
+ message = g_strdup_printf (_("Disconnected â?? %s"),
+ empathy_status_reason_get_default_message (reason));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_ERROR);
+
+ accounts_dialog_status_infobar_set_message (dialog, message);
+ g_free (message);
}
if (!empathy_connectivity_is_online (priv->connectivity))
- message = _("Offline â?? No Network Connection");
+ accounts_dialog_status_infobar_set_message (dialog,
+ _("Offline â?? No Network Connection"));
ephy_spinner_stop (EPHY_SPINNER (priv->throbber));
gtk_widget_show (priv->image_status);
gtk_widget_hide (priv->throbber);
break;
default:
- message = _("Unknown Status");
+ accounts_dialog_status_infobar_set_message (dialog, _("Unknown Status"));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_WARNING);
@@ -322,7 +353,8 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
}
else
{
- message = _("Offline â?? Account Disabled");
+ accounts_dialog_status_infobar_set_message (dialog,
+ _("Offline â?? Account Disabled"));
gtk_info_bar_set_message_type (GTK_INFO_BAR (priv->infobar),
GTK_MESSAGE_WARNING);
@@ -331,8 +363,6 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
gtk_widget_hide (priv->throbber);
}
- message_markup = g_markup_printf_escaped ("<i>%s</i>", message);
- gtk_label_set_markup (GTK_LABEL (priv->label_status), message_markup);
gtk_widget_show (priv->label_status);
if (!creating_account)
@@ -341,7 +371,6 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog,
gtk_widget_hide (priv->infobar);
g_free (status_message);
- g_free (message_markup);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]