[Spice-devel,v2,09/19] Avoid to leak timer in InputsChannel

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

Details

Message ID 17f15325d8f3a5ca91fe413504046b0cb989a5ec.1480085518.git-series.fziglio@redhat.com
State New
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/inputs-channel.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/server/inputs-channel.c b/server/inputs-channel.c
index 7c397a4..99c2888 100644
--- a/server/inputs-channel.c
+++ b/server/inputs-channel.c
@@ -620,6 +620,18 @@  inputs_channel_constructed(GObject *object)
 }
 
 static void
+inputs_channel_finalize(GObject *object)
+{
+    InputsChannel *self = INPUTS_CHANNEL(object);
+    RedsState *reds = red_channel_get_server(RED_CHANNEL(self));
+
+    if (self->key_modifiers_timer) {
+        reds_core_timer_remove(reds, self->key_modifiers_timer);
+    }
+    G_OBJECT_CLASS(inputs_channel_parent_class)->finalize(object);
+}
+
+static void
 inputs_channel_init(InputsChannel *self)
 {
 }
@@ -632,6 +644,7 @@  inputs_channel_class_init(InputsChannelClass *klass)
     RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
 
     object_class->constructed = inputs_channel_constructed;
+    object_class->finalize = inputs_channel_finalize;
 
     channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_INPUTS, NULL);
     channel_class->handle_parsed = inputs_channel_handle_parsed;

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/inputs-channel.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/server/inputs-channel.c b/server/inputs-channel.c
> index 7c397a4..99c2888 100644
> --- a/server/inputs-channel.c
> +++ b/server/inputs-channel.c
> @@ -620,6 +620,18 @@ inputs_channel_constructed(GObject *object)
>  }
>  
>  static void
> +inputs_channel_finalize(GObject *object)
> +{
> +    InputsChannel *self = INPUTS_CHANNEL(object);
> +    RedsState *reds = red_channel_get_server(RED_CHANNEL(self));
> +
> +    if (self->key_modifiers_timer) {
> +        reds_core_timer_remove(reds, self->key_modifiers_timer);
> +    }
> +    G_OBJECT_CLASS(inputs_channel_parent_class)->finalize(object);
> +}
> +
> +static void
>  inputs_channel_init(InputsChannel *self)
>  {
>  }
> @@ -632,6 +644,7 @@ inputs_channel_class_init(InputsChannelClass
> *klass)
>      RedChannelClass *channel_class = RED_CHANNEL_CLASS(klass);
>  
>      object_class->constructed = inputs_channel_constructed;
> +    object_class->finalize = inputs_channel_finalize;
>  
>      channel_class->parser =
> spice_get_client_channel_parser(SPICE_CHANNEL_INPUTS, NULL);
>      channel_class->handle_parsed = inputs_channel_handle_parsed;