From 7c592a5b9bd3e066884eafdd078bd63d6717b415 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 25 May 2021 11:55:20 +0200 Subject: [PATCH] examples: manually destroy the GTK window when shutting down Make the leaks tracer happy, allowing us to detect actual leaks. Fix #341 --- examples/src/bin/gtksink.rs | 7 +++++++ examples/src/bin/gtkvideooverlay.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/examples/src/bin/gtksink.rs b/examples/src/bin/gtksink.rs index 92a491c60..b766d7f1f 100644 --- a/examples/src/bin/gtksink.rs +++ b/examples/src/bin/gtksink.rs @@ -136,6 +136,13 @@ fn create_ui(app: >k::Application) { let timeout_id = RefCell::new(Some(timeout_id)); let pipeline = RefCell::new(Some(pipeline)); app.connect_shutdown(move |_| { + // Optional, by manually destroying the window here we ensure that + // the gst element is destroyed when shutting down instead of having to wait + // for the process to terminate, allowing us to use the leaks tracer. + unsafe { + window.destroy(); + } + // GTK will keep the Application alive for the whole process lifetime. // Wrapping the pipeline in a RefCell> and removing it from it here // ensures the pipeline is actually destroyed when shutting down, allowing us diff --git a/examples/src/bin/gtkvideooverlay.rs b/examples/src/bin/gtkvideooverlay.rs index 52ffdd51c..e49a29943 100644 --- a/examples/src/bin/gtkvideooverlay.rs +++ b/examples/src/bin/gtkvideooverlay.rs @@ -241,6 +241,13 @@ fn create_ui(app: >k::Application) { let timeout_id = RefCell::new(Some(timeout_id)); let pipeline = RefCell::new(Some(pipeline)); app.connect_shutdown(move |_| { + // Optional, by manually destroying the window here we ensure that + // the gst element is destroyed when shutting down instead of having to wait + // for the process to terminate, allowing us to use the leaks tracer. + unsafe { + window.destroy(); + } + // GTK will keep the Application alive for the whole process lifetime. // Wrapping the pipeline in a RefCell> and removing it from it here // ensures the pipeline is actually destroyed when shutting down, allowing us