mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2024-12-22 05:35:20 +00:00
rdw: fix run-time panic because we are not on MainContext
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
3712905ec1
commit
544a407561
@ -99,8 +99,8 @@ impl ClipboardHandler for InnerHandler {
|
||||
selection: ClipboardSelection,
|
||||
mimes: Vec<String>,
|
||||
) -> qemu_display::Result<(String, Vec<u8>)> {
|
||||
// we have to spawn a local future, because clipboard is not Send
|
||||
let (sender, receiver) = futures::channel::oneshot::channel();
|
||||
glib::MainContext::default().invoke(move || {
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
let res = if let Some((clipboard, _)) = clipboard_from_selection(selection) {
|
||||
let m: Vec<_> = mimes.iter().map(|s| s.as_str()).collect();
|
||||
@ -134,6 +134,8 @@ impl ClipboardHandler for InnerHandler {
|
||||
};
|
||||
sender.send(res).unwrap()
|
||||
});
|
||||
});
|
||||
|
||||
match receiver.await {
|
||||
Ok(res) => res,
|
||||
Err(e) => Err(qemu_display::Error::Failed(format!(
|
||||
|
Loading…
Reference in New Issue
Block a user