examples: manually destroy the GTK window when shutting down

Make the leaks tracer happy, allowing us to detect actual leaks.

Fix #341
This commit is contained in:
Guillaume Desmottes 2021-05-25 11:55:20 +02:00
parent 37a352dc35
commit 7c592a5b9b
2 changed files with 14 additions and 0 deletions

View file

@ -136,6 +136,13 @@ fn create_ui(app: &gtk::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<Option<_>> and removing it from it here
// ensures the pipeline is actually destroyed when shutting down, allowing us

View file

@ -241,6 +241,13 @@ fn create_ui(app: &gtk::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<Option<_>> and removing it from it here
// ensures the pipeline is actually destroyed when shutting down, allowing us