[Spice-devel] [PATCH spice-gtk 1/3] MainChannel: move task free from finalize to dispose
Victor Toso
lists at victortoso.com
Thu Oct 22 00:13:54 PDT 2015
Hi,
On Wed, Oct 21, 2015 at 03:52:49PM -0500, Jonathon Jongsma wrote:
> In order to avoid reference cycles, you're supposed to release
> references in dispose, especially to those objects that can hold
> references to yourself. This probably wasn't causing any leaks, since
> the file transfer tasks generally are not alive when the main channel is
> destroyed, but it's more proper.
> ---
> src/channel-main.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/channel-main.c b/src/channel-main.c
> index 3a8c1dd..0a73e92 100644
> --- a/src/channel-main.c
> +++ b/src/channel-main.c
> @@ -405,6 +405,11 @@ static void spice_main_channel_dispose(GObject *obj)
> c->migrate_delayed_id = 0;
> }
>
> + if (c->file_xfer_tasks) {
> + g_hash_table_unref(c->file_xfer_tasks);
> + c->file_xfer_tasks = NULL;
> + }
> +
g_clear_object(&c->file_xfer_tasks);
Looks good either way,
toso
> g_cancellable_cancel(c->cancellable_volume_info);
> g_clear_object(&c->cancellable_volume_info);
>
> @@ -418,8 +423,6 @@ static void spice_main_channel_finalize(GObject *obj)
>
> g_free(c->agent_msg_data);
> agent_free_msg_queue(SPICE_MAIN_CHANNEL(obj));
> - if (c->file_xfer_tasks)
> - g_hash_table_unref(c->file_xfer_tasks);
>
> if (G_OBJECT_CLASS(spice_main_channel_parent_class)->finalize)
> G_OBJECT_CLASS(spice_main_channel_parent_class)->finalize(obj);
> --
> 2.4.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list