From 1084477e032113aefa2aad6d8c0a7360fafaae91 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Thu, 7 Dec 2000 20:29:58 +0000 Subject: [PATCH] Add a bunch of unrefs. Thu Dec 7 15:22:30 2000 Owen Taylor * tests/mainloop-test.c (recurser_start): Add a bunch of unrefs. * gmain.c (g_source_attach): Reference the source when adding (pointed out by Elliot) --- glib/gmain.c | 13 +++++++++++-- gmain.c | 13 +++++++++++-- tests/mainloop-test.c | 4 ++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/glib/gmain.c b/glib/gmain.c index d87022c3..fddaf154 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -752,6 +752,7 @@ g_source_attach (GSource *source, source->context = context; result = source->id = context->next_id++; + source->ref_count++; g_source_list_add (source, context); tmp_list = source->poll_fds; @@ -2618,6 +2619,7 @@ g_timeout_add_full (gint priority, GDestroyNotify notify) { GSource *source; + guint id; g_return_val_if_fail (function != NULL, 0); @@ -2627,7 +2629,10 @@ g_timeout_add_full (gint priority, g_source_set_priority (source, priority); g_source_set_callback (source, function, data, notify); - return g_source_attach (source, NULL); + id = g_source_attach (source, NULL); + g_source_unref (source); + + return id; } /** @@ -2731,6 +2736,7 @@ g_idle_add_full (gint priority, GDestroyNotify notify) { GSource *source; + guint id; g_return_val_if_fail (function != NULL, 0); @@ -2740,7 +2746,10 @@ g_idle_add_full (gint priority, g_source_set_priority (source, priority); g_source_set_callback (source, function, data, notify); - return g_source_attach (source, NULL); + id = g_source_attach (source, NULL); + g_source_unref (source); + + return id; } /** diff --git a/gmain.c b/gmain.c index d87022c3..fddaf154 100644 --- a/gmain.c +++ b/gmain.c @@ -752,6 +752,7 @@ g_source_attach (GSource *source, source->context = context; result = source->id = context->next_id++; + source->ref_count++; g_source_list_add (source, context); tmp_list = source->poll_fds; @@ -2618,6 +2619,7 @@ g_timeout_add_full (gint priority, GDestroyNotify notify) { GSource *source; + guint id; g_return_val_if_fail (function != NULL, 0); @@ -2627,7 +2629,10 @@ g_timeout_add_full (gint priority, g_source_set_priority (source, priority); g_source_set_callback (source, function, data, notify); - return g_source_attach (source, NULL); + id = g_source_attach (source, NULL); + g_source_unref (source); + + return id; } /** @@ -2731,6 +2736,7 @@ g_idle_add_full (gint priority, GDestroyNotify notify) { GSource *source; + guint id; g_return_val_if_fail (function != NULL, 0); @@ -2740,7 +2746,10 @@ g_idle_add_full (gint priority, g_source_set_priority (source, priority); g_source_set_callback (source, function, data, notify); - return g_source_attach (source, NULL); + id = g_source_attach (source, NULL); + g_source_unref (source); + + return id; } /** diff --git a/tests/mainloop-test.c b/tests/mainloop-test.c index aebefd16..2652d63e 100644 --- a/tests/mainloop-test.c +++ b/tests/mainloop-test.c @@ -138,11 +138,13 @@ adder_thread (gpointer data) adder_source = g_io_create_watch (channels[0], G_IO_IN | G_IO_HUP); g_source_set_callback (adder_source, (GSourceFunc)adder_callback, &addr_data, NULL); g_source_attach (adder_source, context); + g_source_unref (adder_source); timeout_source = g_timeout_source_new (10); g_source_set_callback (timeout_source, (GSourceFunc)timeout_callback, &addr_data, NULL); g_source_set_priority (timeout_source, G_PRIORITY_HIGH); g_source_attach (timeout_source, context); + g_source_unref (timeout_source); g_main_run (addr_data.loop); @@ -312,6 +314,7 @@ create_crawler (void) G_LOCK (context_array_lock); g_source_attach (source, context_array->pdata[g_random_int_range (0, context_array->len)]); + g_source_unref (source); G_UNLOCK (context_array_lock); G_LOCK (crawler_array_lock); @@ -359,6 +362,7 @@ recurser_start (gpointer data) source = g_idle_source_new (); g_source_set_callback (source, recurser_idle, context, NULL); g_source_attach (source, context); + g_source_unref (source); G_UNLOCK (context_array_lock); return TRUE; -- 2.34.1