gtk4: Attach main context receiver from the main context's thread

Otherwise it will fail if the sink's state is changed from a different
thread.

See https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio/-/issues/2
This commit is contained in:
Sebastian Dröge 2022-02-04 13:51:31 +02:00
parent 7c872bb92b
commit 858865b731

View file

@ -65,23 +65,23 @@ impl PaintableSink {
// created.
let (send, recv) = mpsc::channel();
context.invoke(glib::clone!(
@weak self as s =>
@weak self as sink =>
move || {
let paintable = Fragile::new(SinkPaintable::new());
send.send(paintable).expect("Somehow we dropped the receiver");
receiver.attach(
None,
glib::clone!(
@weak sink => @default-return glib::Continue(false),
move |action| sink.do_action(action)
),
);
}
));
let paintable = recv.recv().expect("Somehow we dropped the sender");
receiver.attach(
None,
glib::clone!(
@weak self as sink => @default-return glib::Continue(false),
move |action| sink.do_action(action)
),
);
**paintable_storage = Some(paintable);
let imp = self.imp();