mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix(core): return an error when accessing unmanaged state in command (#11958)
closes #11949
This commit is contained in:
5
.changes/unmanaged-state-command.md
Normal file
5
.changes/unmanaged-state-command.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": "patch:bug"
|
||||
---
|
||||
|
||||
Fix panic when invoking a command with an unmanaged state, an error will be returned instead.
|
||||
38
Cargo.lock
generated
38
Cargo.lock
generated
@@ -4858,7 +4858,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.48.5",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6647,9 +6647,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.15"
|
||||
version = "0.17.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67582bd5b65bdff614270e2ea89a1cf15bef71245cc1e5f7ea126977144211d"
|
||||
checksum = "52f9d46a34a05a6a57566bc2bfae066ef07585a6e3fa30fbbdff5936380623f0"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
@@ -7978,9 +7978,9 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.216"
|
||||
version = "1.0.215"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e"
|
||||
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
@@ -8042,9 +8042,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.216"
|
||||
version = "1.0.215"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e"
|
||||
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -9042,7 +9042,7 @@ dependencies = [
|
||||
"tauri-runtime",
|
||||
"tauri-runtime-wry",
|
||||
"tauri-utils 2.1.0",
|
||||
"thiserror 2.0.6",
|
||||
"thiserror 2.0.4",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tray-icon",
|
||||
@@ -9110,7 +9110,7 @@ dependencies = [
|
||||
"tauri-macos-sign",
|
||||
"tauri-utils 2.1.0",
|
||||
"tempfile",
|
||||
"thiserror 2.0.6",
|
||||
"thiserror 2.0.4",
|
||||
"time",
|
||||
"ureq",
|
||||
"url",
|
||||
@@ -9230,7 +9230,7 @@ dependencies = [
|
||||
"sha2",
|
||||
"syn 2.0.90",
|
||||
"tauri-utils 2.1.0",
|
||||
"thiserror 2.0.6",
|
||||
"thiserror 2.0.4",
|
||||
"time",
|
||||
"url",
|
||||
"uuid",
|
||||
@@ -9369,7 +9369,7 @@ dependencies = [
|
||||
"serde",
|
||||
"tauri",
|
||||
"tauri-plugin 2.0.3",
|
||||
"thiserror 2.0.6",
|
||||
"thiserror 2.0.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9384,7 +9384,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tauri-utils 2.1.0",
|
||||
"thiserror 2.0.6",
|
||||
"thiserror 2.0.4",
|
||||
"url",
|
||||
"windows",
|
||||
]
|
||||
@@ -9536,7 +9536,7 @@ dependencies = [
|
||||
"serial_test",
|
||||
"serialize-to-javascript",
|
||||
"swift-rs",
|
||||
"thiserror 2.0.6",
|
||||
"thiserror 2.0.4",
|
||||
"toml 0.8.19",
|
||||
"url",
|
||||
"urlpattern",
|
||||
@@ -9637,11 +9637,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.6"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47"
|
||||
checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490"
|
||||
dependencies = [
|
||||
"thiserror-impl 2.0.6",
|
||||
"thiserror-impl 2.0.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -9657,9 +9657,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.6"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312"
|
||||
checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -10801,7 +10801,7 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -60,12 +60,12 @@ impl<T: Send + Sync + std::fmt::Debug> std::fmt::Debug for State<'_, T> {
|
||||
impl<'r, 'de: 'r, T: Send + Sync + 'static, R: Runtime> CommandArg<'de, R> for State<'r, T> {
|
||||
/// Grabs the [`State`] from the [`CommandItem`]. This will never fail.
|
||||
fn from_command(command: CommandItem<'de, R>) -> Result<Self, InvokeError> {
|
||||
Ok(command.message.state_ref().try_get().unwrap_or_else(|| {
|
||||
panic!(
|
||||
command.message.state_ref().try_get().ok_or_else(|| {
|
||||
InvokeError::from_anyhow(anyhow::anyhow!(
|
||||
"state not managed for field `{}` on command `{}`. You must call `.manage()` before using this command",
|
||||
command.key, command.name
|
||||
)
|
||||
}))
|
||||
))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user