verification: Fix crash when trying to access the camera
This commit is contained in:
parent
96237c5271
commit
76cf6592ca
4 changed files with 26 additions and 111 deletions
112
Cargo.lock
generated
112
Cargo.lock
generated
|
@ -109,11 +109,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "ashpd"
|
||||
version = "0.4.0-alpha.1"
|
||||
version = "0.4.0-alpha.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "045dde3c95c8f64855f286504bfb516f4d35f00b717023141b9e13daff2a73d9"
|
||||
checksum = "974f7451ac6438b57257de542be1ffc7a7c725b6f51c47dc19351e49f1c24687"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"enumflags2",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
|
@ -126,6 +125,7 @@ dependencies = [
|
|||
"rand 0.8.5",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"url",
|
||||
"zbus 3.6.2",
|
||||
|
@ -173,21 +173,6 @@ dependencies = [
|
|||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-global-executor"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-executor",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"blocking",
|
||||
"futures-lite",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-io"
|
||||
version = "1.12.0"
|
||||
|
@ -246,32 +231,6 @@ dependencies = [
|
|||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-std"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-global-executor",
|
||||
"async-io",
|
||||
"async-lock",
|
||||
"crossbeam-utils",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-lite",
|
||||
"gloo-timers",
|
||||
"kv-log-macro",
|
||||
"log",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
"wasm-bindgen-futures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-stream"
|
||||
version = "0.3.3"
|
||||
|
@ -319,12 +278,6 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-waker"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a"
|
||||
|
||||
[[package]]
|
||||
name = "atomic_refcell"
|
||||
version = "0.1.8"
|
||||
|
@ -456,20 +409,6 @@ dependencies = [
|
|||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "blocking"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8"
|
||||
dependencies = [
|
||||
"async-channel",
|
||||
"async-lock",
|
||||
"async-task",
|
||||
"atomic-waker",
|
||||
"fastrand",
|
||||
"futures-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.11.1"
|
||||
|
@ -789,16 +728,6 @@ dependencies = [
|
|||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
|
||||
dependencies = [
|
||||
"quote 1.0.23",
|
||||
"syn 1.0.107",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctr"
|
||||
version = "0.9.2"
|
||||
|
@ -1722,18 +1651,6 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||
|
||||
[[package]]
|
||||
name = "gloo-timers"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.16.3"
|
||||
|
@ -2487,15 +2404,6 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kv-log-macro"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f"
|
||||
dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -2671,7 +2579,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"value-bag",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4757,6 +4664,7 @@ dependencies = [
|
|||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tracing",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
|
@ -5016,16 +4924,6 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "value-bag"
|
||||
version = "1.0.0-alpha.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55"
|
||||
dependencies = [
|
||||
"ctor",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
@ -5488,6 +5386,7 @@ dependencies = [
|
|||
"futures-sink",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"lazy_static",
|
||||
"nix 0.25.1",
|
||||
"once_cell",
|
||||
"ordered-stream 0.1.2",
|
||||
|
@ -5496,6 +5395,7 @@ dependencies = [
|
|||
"serde_repr",
|
||||
"sha1 0.10.5",
|
||||
"static_assertions",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"uds_windows",
|
||||
"winapi",
|
||||
|
|
|
@ -37,10 +37,11 @@ futures = "0.3"
|
|||
rand = "0.8"
|
||||
indexmap = "1.6.2"
|
||||
qrcode = "0.12.0"
|
||||
ashpd = { version = "0.4.0-alpha.1", features = [
|
||||
ashpd = { version = "0.4.0-alpha.2", default-features = false, features = [
|
||||
"gtk4",
|
||||
"pipewire",
|
||||
"tracing",
|
||||
"tokio",
|
||||
] }
|
||||
gst = { version = "0.19.1", package = "gstreamer" }
|
||||
gst_base = { version = "0.19.1", package = "gstreamer-base" }
|
||||
|
|
|
@ -7,6 +7,7 @@ use once_cell::sync::Lazy;
|
|||
use tokio::time::timeout;
|
||||
|
||||
use super::camera_paintable::CameraPaintable;
|
||||
use crate::spawn_tokio;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
@ -72,7 +73,11 @@ impl Camera {
|
|||
async fn paintable_internal(&self) -> Option<CameraPaintable> {
|
||||
if let Some(paintable) = self.imp().paintable.upgrade() {
|
||||
Some(paintable)
|
||||
} else if let Ok(Some((stream_fd, streams))) = camera::request().await {
|
||||
} else if let Ok(Some((stream_fd, streams))) =
|
||||
spawn_tokio!(async move { camera::request().await })
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
let paintable = CameraPaintable::new(stream_fd, streams).await;
|
||||
self.imp().paintable.set(Some(&paintable));
|
||||
Some(paintable)
|
||||
|
|
|
@ -350,8 +350,11 @@ impl IdentityVerification {
|
|||
session.user().unwrap()
|
||||
};
|
||||
|
||||
let supported_methods =
|
||||
SupportedMethods::with_camera(Camera::default().has_camera().await.unwrap_or_default());
|
||||
let has_camera =
|
||||
spawn_tokio!(async move { Camera::default().has_camera().await.unwrap_or_default() })
|
||||
.await
|
||||
.unwrap();
|
||||
let supported_methods = SupportedMethods::with_camera(has_camera);
|
||||
|
||||
if let Some(identity) = user.crypto_identity().await {
|
||||
let handle = spawn_tokio!(async move {
|
||||
|
@ -954,7 +957,13 @@ impl Context {
|
|||
wait![self];
|
||||
|
||||
// Check whether we have a camera
|
||||
if !Camera::default().has_camera().await.unwrap_or_default() {
|
||||
let has_camera =
|
||||
spawn_tokio!(
|
||||
async move { Camera::default().has_camera().await.unwrap_or_default() }
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
if !has_camera {
|
||||
self.supported_methods.remove(SupportedMethods::QR_SCAN);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue