mirror of
https://github.com/rustdesk/qemu-display.git
synced 2026-10-27 14:40:04 +00:00
qd: replace RefCell with async mutex
Avoid potential run-time borrowing errors across async points. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
1 parent
ab44cda4b9
commit
8c5fa2a4f9
3 files changed
+23
-15
No files matched your search
@@ -20,12 +20,15 @@ impl Handler {
|
||||
widget
|
||||
.model()
|
||||
.connect_items_changed(clone!(@weak widget => move |model, pos, _rm, add| {
|
||||
for pos in pos..pos + add {
|
||||
let item = model.item(pos).unwrap();
|
||||
if let Some(dev) = item.downcast_ref::<rdw::UsbDevice>().unwrap().device() {
|
||||
item.set_property("active", usbredir.is_device_connected(&dev)).unwrap();
|
||||
let usbredir = usbredir.clone();
|
||||
MainContext::default().spawn_local(clone!(@weak model => async move {
|
||||
for pos in pos..pos + add {
|
||||
let item = model.item(pos).unwrap();
|
||||
if let Some(dev) = item.downcast_ref::<rdw::UsbDevice>().unwrap().device() {
|
||||
item.set_property("active", usbredir.is_device_connected(&dev).await).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}));
|
||||
|
||||
let usbredir = self.usbredir.clone();
|
||||
@@ -55,7 +58,7 @@ impl Handler {
|
||||
widget
|
||||
.set_property("free-channels", usbredir.n_free_channels().await)
|
||||
.unwrap();
|
||||
let mut n = usbredir.receive_n_free_channels();
|
||||
let mut n = usbredir.receive_n_free_channels().await;
|
||||
while let Some(n) = n.next().await {
|
||||
widget.set_property("free-channels", n).unwrap();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user