Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2023-04-14 12:46:43 +0300
committerSebastian Dröge <sebastian@centricular.com>2023-04-14 12:46:43 +0300
commit47159ad3c224e01e634a66d0afa3baa43066c228 (patch)
treede56561d41545c31d79eaf73721f8b749941f66b /video
parentaabfb61834375301e313fd8fd8b8fc6849b57695 (diff)
Make sure to keep around and drop bus watches after usage in all the examples
Diffstat (limited to 'video')
-rw-r--r--video/gtk4/examples/gtksink.rs54
1 files changed, 28 insertions, 26 deletions
diff --git a/video/gtk4/examples/gtksink.rs b/video/gtk4/examples/gtksink.rs
index bdb3da2e1..3dddce252 100644
--- a/video/gtk4/examples/gtksink.rs
+++ b/video/gtk4/examples/gtksink.rs
@@ -95,42 +95,44 @@ fn create_ui(app: &gtk::Application) {
.expect("Unable to set the pipeline to the `Playing` state");
let app_weak = app.downgrade();
- bus.add_watch_local(move |_, msg| {
- use gst::MessageView;
-
- let app = match app_weak.upgrade() {
- Some(app) => app,
- None => return glib::Continue(false),
- };
-
- match msg.view() {
- MessageView::Eos(..) => app.quit(),
- MessageView::Error(err) => {
- println!(
- "Error from {:?}: {} ({:?})",
- err.src().map(|s| s.path_string()),
- err.error(),
- err.debug()
- );
- app.quit();
- }
- _ => (),
- };
-
- glib::Continue(true)
- })
- .expect("Failed to add bus watch");
+ let bus_watch = bus
+ .add_watch_local(move |_, msg| {
+ use gst::MessageView;
+
+ let app = match app_weak.upgrade() {
+ Some(app) => app,
+ None => return glib::Continue(false),
+ };
+
+ match msg.view() {
+ MessageView::Eos(..) => app.quit(),
+ MessageView::Error(err) => {
+ println!(
+ "Error from {:?}: {} ({:?})",
+ err.src().map(|s| s.path_string()),
+ err.error(),
+ err.debug()
+ );
+ app.quit();
+ }
+ _ => (),
+ };
+
+ glib::Continue(true)
+ })
+ .expect("Failed to add bus watch");
let timeout_id = RefCell::new(Some(timeout_id));
let pipeline = RefCell::new(Some(pipeline));
+ let bus_watch = RefCell::new(Some(bus_watch));
app.connect_shutdown(move |_| {
window.close();
+ drop(bus_watch.borrow_mut().take());
if let Some(pipeline) = pipeline.borrow_mut().take() {
pipeline
.set_state(gst::State::Null)
.expect("Unable to set the pipeline to the `Null` state");
- pipeline.bus().unwrap().remove_watch().unwrap();
}
if let Some(timeout_id) = timeout_id.borrow_mut().take() {