[gnome-utils] [gdict] Remove the connection check timeout



commit 6e4c746e68fbf50306d8b0227de1fba3fc15c2ef
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Sep 4 00:03:33 2009 +0100

    [gdict] Remove the connection check timeout
    
    It is possible that the context is destroyed while the timeout we
    use to check if there is a connection is still running; inside the
    timeout callback we access the context data structure, and if the
    object has been finalized then we end up in a SIGSEGV.
    
    We need to remove the timeout source when forcing a disconnect, if
    one is installed; the finalization sequence forces a disconnection
    thus we should always be safe as houses.
    
    Fixes bug:
    
      http://bugzilla.gnome.org/show_bug.cgi?id=502582

 gnome-dictionary/libgdict/gdict-client-context.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/gnome-dictionary/libgdict/gdict-client-context.c b/gnome-dictionary/libgdict/gdict-client-context.c
index c93a1ad..316e73a 100644
--- a/gnome-dictionary/libgdict/gdict-client-context.c
+++ b/gnome-dictionary/libgdict/gdict-client-context.c
@@ -941,7 +941,13 @@ static void
 gdict_client_context_force_disconnect (GdictClientContext *context)
 {
   GdictClientContextPrivate *priv = context->priv;
-  
+
+  if (priv->timeout_id)
+    {
+      g_source_remove (priv->timeout_id);
+      priv->timeout_id = 0;
+    }
+
   if (priv->source_id)
     {
       g_source_remove (priv->source_id);
@@ -1840,6 +1846,9 @@ check_for_connection (gpointer data)
            context->priv->is_connecting ? "true" : "false");
 #endif
 
+  if (context == NULL)
+    return FALSE;
+
   if (context->priv->is_connecting)
     {
       GError *err = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]