event: fix various reference ownership issues
This commit is contained in:
+7
-1
@@ -147,7 +147,7 @@ G_DEFINE_CONSTRUCTOR (init_event_cache_map);
|
||||
static void
|
||||
init_event_cache_map (void)
|
||||
{
|
||||
event_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref);
|
||||
event_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
|
||||
}
|
||||
|
||||
G_DEFINE_DESTRUCTOR (destroy_event_cache_map);
|
||||
@@ -155,6 +155,12 @@ G_DEFINE_DESTRUCTOR (destroy_event_cache_map);
|
||||
static void
|
||||
destroy_event_cache_map (void)
|
||||
{
|
||||
GList *events;
|
||||
|
||||
/* Destroy all events */
|
||||
events = g_hash_table_get_values (event_cache);
|
||||
g_list_free_full (events, g_object_unref);
|
||||
|
||||
g_hash_table_destroy (event_cache);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define MAX_MINUTES (7 * MINUTES_PER_DAY)
|
||||
|
||||
#define gcal_clear_datetime(dt) g_clear_pointer (dt, g_date_time_unref)
|
||||
#define gcal_clear_timeout(pp) { if (pp && *pp) { g_source_remove (*pp); *pp = 0; } }
|
||||
|
||||
/**
|
||||
* GcalWindowViewType:
|
||||
|
||||
+6
-18
@@ -1283,23 +1283,11 @@ gcal_window_finalize (GObject *object)
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
if (window->save_geometry_timeout_id > 0)
|
||||
{
|
||||
g_source_remove (window->save_geometry_timeout_id);
|
||||
window->save_geometry_timeout_id = 0;
|
||||
}
|
||||
g_critical ("Finalizing");
|
||||
|
||||
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 (window->refresh_timeout_id > 0)
|
||||
{
|
||||
g_source_remove (window->refresh_timeout_id);
|
||||
window->refresh_timeout_id = 0;
|
||||
}
|
||||
gcal_clear_timeout (&window->save_geometry_timeout_id);
|
||||
gcal_clear_timeout (&window->open_edit_dialog_timeout_id);
|
||||
gcal_clear_timeout (&window->refresh_timeout_id);
|
||||
|
||||
/* If we have a queued event to delete, remove it now */
|
||||
if (window->event_to_delete)
|
||||
@@ -1308,7 +1296,7 @@ gcal_window_finalize (GObject *object)
|
||||
g_clear_object (&window->event_to_delete);
|
||||
}
|
||||
|
||||
if (window->event_creation_data != NULL)
|
||||
if (window->event_creation_data)
|
||||
{
|
||||
g_clear_pointer (&window->event_creation_data->start_date, g_date_time_unref);
|
||||
g_clear_pointer (&window->event_creation_data->end_date, g_date_time_unref);
|
||||
@@ -1318,7 +1306,7 @@ gcal_window_finalize (GObject *object)
|
||||
g_clear_object (&window->manager);
|
||||
g_clear_object (&window->views_switcher);
|
||||
|
||||
g_free (window->active_date);
|
||||
g_clear_pointer (&window->active_date, g_free);
|
||||
|
||||
G_OBJECT_CLASS (gcal_window_parent_class)->finalize (object);
|
||||
|
||||
|
||||
@@ -1842,7 +1842,7 @@ gcal_year_view_component_added (ECalDataModelSubscriber *subscriber,
|
||||
|
||||
/* Add the event to the cache */
|
||||
for (i = start_month; i <= end_month; i++)
|
||||
g_ptr_array_add (self->events[i], event);
|
||||
g_ptr_array_add (self->events[i], g_object_ref (event));
|
||||
|
||||
update_sidebar (self);
|
||||
|
||||
@@ -2015,7 +2015,7 @@ gcal_year_view_init (GcalYearView *self)
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
self->events[i] = g_ptr_array_new ();
|
||||
self->events[i] = g_ptr_array_new_with_free_func (g_object_unref);
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user