diff options
author | Dan Vrátil <dvratil@redhat.com> | 2012-06-27 20:03:54 +0800 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2012-06-27 20:18:39 +0800 |
commit | 2a86155e711e620bcfb1bb3dcfe1782991f0dc5c (patch) | |
tree | 28031771d74c9b6396fd787cffb89facf5e1e42b /addressbook | |
parent | 255e0529040baae67e3d70f1030ce248fd61856d (diff) | |
download | gsoc2013-evolution-2a86155e711e620bcfb1bb3dcfe1782991f0dc5c.tar.gz gsoc2013-evolution-2a86155e711e620bcfb1bb3dcfe1782991f0dc5c.tar.zst gsoc2013-evolution-2a86155e711e620bcfb1bb3dcfe1782991f0dc5c.zip |
Bug #674427 - Crash when formatting contact in addressbook
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/gui/widgets/eab-contact-display.c | 51 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-formatter.c | 11 | ||||
-rw-r--r-- | addressbook/gui/widgets/eab-contact-formatter.h | 4 |
3 files changed, 43 insertions, 23 deletions
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c index a6293f584f..2c9912fa65 100644 --- a/addressbook/gui/widgets/eab-contact-display.c +++ b/addressbook/gui/widgets/eab-contact-display.c @@ -54,7 +54,11 @@ struct _EABContactDisplayPrivate { EContact *contact; - EABContactFormatter *formatter; + + EABContactDisplayMode mode; + gboolean show_maps; + + GCancellable *formatter_cancellable; }; enum { @@ -186,20 +190,34 @@ contact_formatting_finished (GObject *object, g_free (html); g_object_unref (stream); + g_object_unref (object); + g_clear_object (&display->priv->formatter_cancellable); } static void load_contact (EABContactDisplay *display) { + EABContactFormatter *formatter; + + if (display->priv->formatter_cancellable) { + g_cancellable_cancel (display->priv->formatter_cancellable); + g_clear_object (&display->priv->formatter_cancellable); + } + if (!display->priv->contact) { e_web_view_clear (E_WEB_VIEW (display)); return; } + formatter = eab_contact_formatter_new ( + display->priv->mode, + display->priv->show_maps); + + display->priv->formatter_cancellable = g_cancellable_new (); + eab_contact_formatter_format_contact_async ( - display->priv->formatter, - display->priv->contact, - NULL, + formatter, display->priv->contact, + display->priv->formatter_cancellable, (GAsyncReadyCallback) contact_formatting_finished, display); } @@ -522,11 +540,6 @@ eab_contact_display_init (EABContactDisplay *display) display->priv = EAB_CONTACT_DISPLAY_GET_PRIVATE (display); - display->priv->formatter = g_object_new ( - EAB_TYPE_CONTACT_FORMATTER, - "display-mode", EAB_CONTACT_DISPLAY_RENDER_NORMAL, - "render-maps", FALSE, NULL); - web_view = E_WEB_VIEW (display); ui_manager = e_web_view_get_ui_manager (web_view); @@ -598,7 +611,7 @@ eab_contact_display_get_mode (EABContactDisplay *display) { g_return_val_if_fail (EAB_IS_CONTACT_DISPLAY (display), 0); - return eab_contact_formatter_get_display_mode (display->priv->formatter); + return display->priv->mode; } void @@ -607,14 +620,10 @@ eab_contact_display_set_mode (EABContactDisplay *display, { g_return_if_fail (EAB_IS_CONTACT_DISPLAY (display)); - if (eab_contact_formatter_get_display_mode ( - display->priv->formatter) == mode) { - + if (display->priv->mode == mode) return; - }; - eab_contact_formatter_set_display_mode ( - display->priv->formatter, mode); + display->priv->mode = mode; load_contact (display); @@ -626,7 +635,7 @@ eab_contact_display_get_show_maps (EABContactDisplay *display) { g_return_val_if_fail (EAB_IS_CONTACT_DISPLAY (display), FALSE); - return eab_contact_formatter_get_render_maps (display->priv->formatter); + return display->priv->show_maps; } void @@ -635,14 +644,10 @@ eab_contact_display_set_show_maps (EABContactDisplay *display, { g_return_if_fail (EAB_IS_CONTACT_DISPLAY (display)); - if (eab_contact_formatter_get_render_maps ( - display->priv->formatter) == show_maps) { - + if ((display->priv->show_maps ? 1 : 0) == (show_maps ? 1 : 0)) return; - } - eab_contact_formatter_set_render_maps ( - display->priv->formatter, show_maps); + display->priv->show_maps = show_maps; load_contact (display); diff --git a/addressbook/gui/widgets/eab-contact-formatter.c b/addressbook/gui/widgets/eab-contact-formatter.c index 43d68b163f..ce6825aa9d 100644 --- a/addressbook/gui/widgets/eab-contact-formatter.c +++ b/addressbook/gui/widgets/eab-contact-formatter.c @@ -1159,6 +1159,17 @@ eab_contact_formatter_init (EABContactFormatter *formatter) formatter->priv->render_maps = FALSE; } +EABContactFormatter * +eab_contact_formatter_new (EABContactDisplayMode mode, + gboolean render_maps) +{ + return g_object_new (EAB_TYPE_CONTACT_FORMATTER, + "display-mode", mode, + "render-maps", render_maps, + NULL); +} + + void eab_contact_formatter_set_display_mode (EABContactFormatter *formatter, EABContactDisplayMode mode) diff --git a/addressbook/gui/widgets/eab-contact-formatter.h b/addressbook/gui/widgets/eab-contact-formatter.h index e1f706eb24..7348f89f0c 100644 --- a/addressbook/gui/widgets/eab-contact-formatter.h +++ b/addressbook/gui/widgets/eab-contact-formatter.h @@ -58,6 +58,10 @@ struct _EABContactFormatterClass { GType eab_contact_formatter_get_type (); +EABContactFormatter* + eab_contact_formatter_new (EABContactDisplayMode mode, + gboolean render_maps); + void eab_contact_formatter_set_render_maps (EABContactFormatter *formatter, gboolean render_maps); |