[Spice-devel,v2,16/19] cursor: Avoid cursor item leak

Submitted by Frediano Ziglio on Nov. 25, 2016, 2:52 p.m.

Details

Message ID 051a2f8549a0a8140fc1567a925942b77416bac7.1480085518.git-series.fziglio@redhat.com
State Accepted
Headers show
Series "Start cleaning objects on destruction" ( rev: 4 3 2 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 25, 2016, 2:52 p.m.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/cursor-channel.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Patch hide | download patch | download mbox

diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index 202ec89..e421bf7 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -438,10 +438,25 @@  void cursor_channel_connect(CursorChannel *cursor, RedClient *client, RedsStream
 }
 
 static void
+cursor_channel_finalize(GObject *object)
+{
+    CursorChannel *self = CURSOR_CHANNEL(object);
+
+    if (self->item) {
+        cursor_item_unref(self->item);
+    }
+
+    G_OBJECT_CLASS(cursor_channel_parent_class)->finalize(object);
+}
+
+static void
 cursor_channel_class_init(CursorChannelClass *klass)
 {
+    GObjectClass *object_class = G_OBJECT_CLASS(klass);
     RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
 
+    object_class->finalize = cursor_channel_finalize;
+
     channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_CURSOR, NULL);
     channel_class->handle_parsed = red_channel_client_handle_message;
 

Comments

On Fri, 2016-11-25 at 14:52 +0000, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
> ---
>  server/cursor-channel.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 202ec89..e421bf7 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -438,10 +438,25 @@ void cursor_channel_connect(CursorChannel
> *cursor, RedClient *client, RedsStream
>  }
>  
>  static void
> +cursor_channel_finalize(GObject *object)
> +{
> +    CursorChannel *self = CURSOR_CHANNEL(object);
> +
> +    if (self->item) {
> +        cursor_item_unref(self->item);
> +    }
> +
> +    G_OBJECT_CLASS(cursor_channel_parent_class)->finalize(object);
> +}
> +
> +static void
>  cursor_channel_class_init(CursorChannelClass *klass)
>  {
> +    GObjectClass *object_class = G_OBJECT_CLASS(klass);
>      RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
>  
> +    object_class->finalize = cursor_channel_finalize;
> +
>      channel_class->parser =
> spice_get_client_channel_parser(SPICE_CHANNEL_CURSOR, NULL);
>      channel_class->handle_parsed =
> red_channel_client_handle_message;
>