From 5cdf3c8797a3a68d062a65f45c464a7c6e581c9e Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Tue, 8 Dec 2009 10:58:00 -0600 Subject: Handle the case where error definitions don't include certain fields Some error definitions don't specify a title or secondary text. Handle these situations properly. This was a regression caused by my refactoring. Fixes bug #604085. --- e-util/e-alert.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'e-util/e-alert.c') diff --git a/e-util/e-alert.c b/e-util/e-alert.c index ff8801ff9e..bc116f07ef 100644 --- a/e-util/e-alert.c +++ b/e-util/e-alert.c @@ -608,8 +608,11 @@ e_alert_get_title (EAlert *alert) g_return_val_if_fail (alert && alert->priv && alert->priv->definition, NULL); formatted = g_string_new (""); - e_alert_format_string (formatted, alert->priv->definition->title, - alert->priv->args, FALSE); + if (alert->priv->definition->title) { + e_alert_format_string (formatted, + alert->priv->definition->title, + alert->priv->args, FALSE); + } return g_string_free (formatted, FALSE); } @@ -621,8 +624,15 @@ e_alert_get_primary_text (EAlert *alert) formatted = g_string_new (""); if (alert->priv->definition) - e_alert_format_string (formatted, alert->priv->definition->primary, - alert->priv->args, FALSE); + if (alert->priv->definition->primary) { + e_alert_format_string (formatted, + alert->priv->definition->primary, + alert->priv->args, FALSE); + } else { + char *title = e_alert_get_title (alert); + g_string_append (formatted, title); + g_free (title); + } else { g_string_append_printf(formatted, _("Internal error, unknown error '%s' requested"), @@ -639,8 +649,11 @@ e_alert_get_secondary_text (EAlert *alert) g_return_val_if_fail (alert && alert->priv && alert->priv->definition, NULL); formatted = g_string_new (""); - e_alert_format_string (formatted, alert->priv->definition->secondary, - alert->priv->args, TRUE); + if (alert->priv->definition->secondary) { + e_alert_format_string (formatted, + alert->priv->definition->secondary, + alert->priv->args, TRUE); + } return g_string_free (formatted, FALSE); } -- cgit v1.2.3