[Spice-devel,spice-server,10/20] Avoid to leak timer in InputsChannel

Submitted by Frediano Ziglio on Nov. 24, 2016, 5:38 p.m.

Details

Message ID 20161124173907.3341-11-fziglio@redhat.com
State Accepted
Commit e1cc694a729b44d81674c0d54edd456c0f474744
Headers show
Series "Start cleaning objects on destruction" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 24, 2016, 5:38 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;