diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-09-03 17:34:49 +0800 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-09-03 17:34:49 +0800 |
commit | b50d7c49a1e5ac9dc43befe60a4296240b8d093e (patch) | |
tree | 8f8b34990fe45e04b4408a69533b4e29476ab70f /libempathy-gtk | |
parent | 415b48c96ad03fa4949268d0ce9645f02005a818 (diff) | |
download | gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.tar gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.tar.gz gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.tar.bz2 gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.tar.lz gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.tar.xz gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.tar.zst gsoc2013-empathy-b50d7c49a1e5ac9dc43befe60a4296240b8d093e.zip |
Remove an idle handler when EmpathyChat is destroyed
This prevents the idle handler potentially running after the EmpathyChat has
been destroyed, and accessing freed memory. Closes: bgo#628156
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 15da94c81..36455f3d9 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -99,6 +99,9 @@ struct _EmpathyChatPriv { gulong delete_range_id; gulong notify_cursor_position_id; + /* Source func ID for update_misspelled_words() */ + guint update_misspelled_words_id; + GtkWidget *widget; GtkWidget *hpaned; GtkWidget *vbox_left; @@ -2291,6 +2294,7 @@ static gboolean update_misspelled_words (gpointer data) { EmpathyChat *chat = EMPATHY_CHAT (data); + EmpathyChatPriv *priv = GET_PRIV (chat); GtkTextBuffer *buffer; GtkTextIter iter; gint length; @@ -2301,6 +2305,9 @@ update_misspelled_words (gpointer data) length = gtk_text_iter_get_offset (&iter); chat_input_text_buffer_insert_text_cb (buffer, &iter, NULL, length, chat); + + priv->update_misspelled_words_id = 0; + return FALSE; } @@ -2331,7 +2338,8 @@ conf_spell_checking_cb (GSettings *gsettings_chat, /* Possibly changed dictionaries, * update misspelled words. Need to do so in idle * so the spell checker is updated. */ - g_idle_add (update_misspelled_words, chat); + priv->update_misspelled_words_id = + g_idle_add (update_misspelled_words, chat); } return; @@ -2364,7 +2372,8 @@ conf_spell_checking_cb (GSettings *gsettings_chat, /* Mark misspelled words in the existing buffer. * Need to do so in idle so the spell checker is updated. */ - g_idle_add (update_misspelled_words, chat); + priv->update_misspelled_words_id = + g_idle_add (update_misspelled_words, chat); } else { GtkTextTagTable *table; GtkTextTag *tag; @@ -2583,6 +2592,9 @@ chat_finalize (GObject *object) DEBUG ("Finalized: %p", object); + if (priv->update_misspelled_words_id != 0) + g_source_remove (priv->update_misspelled_words_id); + g_object_unref (priv->gsettings_chat); g_object_unref (priv->gsettings_ui); |