[gnome-calendar] window: avoid a crashing timeout



commit 9fcb22403279cee5a7a65088df8c7bd62a5b723e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jun 29 23:59:23 2016 -0300

    window: avoid a crashing timeout
    
    If the user quickly performs a search, open up the calendar
    and close it immediately after, the timeout for showing the
    event is mistakenly called after the window is destroyed and
    causes Calendar to crash.
    
    Fix that by keeping the source id tracked, and realizing it
    on finalize().

 src/gcal-window.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 88e6884..6db7b61 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -113,6 +113,7 @@ struct _GcalWindow
   GtkWidget           *source_dialog;
   gint                 refresh_timeout;
   gint                 refresh_timeout_id;
+  gint                 open_edit_dialog_timeout_id;
 
   /* temp to keep event_creation */
   gboolean             open_edit_dialog;
@@ -1232,16 +1233,17 @@ schedule_open_edit_dialog_by_uuid (OpenEditDialogData *edit_dialog_data)
   widgets = gcal_view_get_children_by_uuid (GCAL_VIEW (window->month_view), edit_dialog_data->uuid);
   if (widgets != NULL)
     {
+      window->open_edit_dialog_timeout_id = 0;
+
       event_activated (NULL, widgets->data, edit_dialog_data->window);
       g_list_free (widgets);
       g_free (edit_dialog_data->uuid);
       g_free (edit_dialog_data);
-      return FALSE;
-    }
-  else
-    {
-      return TRUE;
+
+      return G_SOURCE_REMOVE;
     }
+
+  return G_SOURCE_CONTINUE;
 }
 
 static void
@@ -1460,6 +1462,12 @@ gcal_window_finalize (GObject *object)
       window->save_geometry_timeout_id = 0;
     }
 
+  if (window->open_edit_dialog_timeout_id > 0)
+    {
+      g_source_remove (window->open_edit_dialog_timeout_id);
+      window->open_edit_dialog_timeout_id = 0;
+    }
+
   /* If we have a queued event to delete, remove it now */
   if (window->event_to_delete)
     {
@@ -1703,6 +1711,8 @@ gcal_window_open_event_by_uuid (GcalWindow  *window,
       OpenEditDialogData *edit_dialog_data = g_new0 (OpenEditDialogData, 1);
       edit_dialog_data->window = window;
       edit_dialog_data->uuid = g_strdup (uuid);
-      g_timeout_add_seconds (2, (GSourceFunc) schedule_open_edit_dialog_by_uuid, edit_dialog_data);
+      window->open_edit_dialog_timeout_id = g_timeout_add_seconds (2,
+                                                                   (GSourceFunc) 
schedule_open_edit_dialog_by_uuid,
+                                                                   edit_dialog_data);
     }
 }


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