You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since 0.15, tray_icon::Icon is not Sync anymore on Windows. This is easily visible in the docs for 0.15 vs 0.14. At least on Linux Icon is still Sync which makes for an awkward portability gotcha.
Test program:
fncheck_sync<T:Sync>(x:T) -> T{
x
}fnmain(){let icon = tray_icon::Icon::from_rgba(vec![],0,0).unwrap();check_sync(icon);}
Compiler error (x86_64-pc-windows-gnu):
error[E0277]: `*mut c_void` cannot be shared between threads safely
--> src/main.rs:7:16
|
7 | check_sync(icon);
| ---------- ^^^^ `*mut c_void` cannot be shared between threads safely
| |
| required by a bound introduced by this call
|
= help: within `tray_icon::platform_impl::platform::icon::RaiiIcon`, the trait `Sync` is not implemented for `*mut c_void`, which is required by `tray_icon::Icon: Sync`
note: required because it appears within the type `tray_icon::platform_impl::platform::icon::RaiiIcon`
--> /home/mara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tray-icon-0.15.1/src/platform_impl/windows/icon.rs:58:8
|
58 | struct RaiiIcon {
| ^^^^^^^^
= note: required for `Arc<tray_icon::platform_impl::platform::icon::RaiiIcon>` to implement `Sync`
note: required because it appears within the type `tray_icon::platform_impl::platform::icon::WinIcon`
--> /home/mara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tray-icon-0.15.1/src/platform_impl/windows/icon.rs:63:19
|
63 | pub(crate) struct WinIcon {
| ^^^^^^^
note: required because it appears within the type `tray_icon::Icon`
--> /home/mara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tray-icon-0.15.1/src/icon.rs:117:12
|
117 | pub struct Icon {
| ^^^^
note: required by a bound in `check_sync`
--> src/main.rs:1:18
|
1 | fn check_sync<T: Sync>(x: T) -> T {
| ^^^^ required by this bound in `check_sync`
error[E0277]: `*mut c_void` cannot be sent between threads safely
--> src/main.rs:7:16
|
7 | check_sync(icon);
| ---------- ^^^^ `*mut c_void` cannot be sent between threads safely
| |
| required by a bound introduced by this call
|
= help: within `tray_icon::platform_impl::platform::icon::RaiiIcon`, the trait `Send` is not implemented for `*mut c_void`, which is required by `tray_icon::Icon: Sync`
note: required because it appears within the type `tray_icon::platform_impl::platform::icon::RaiiIcon`
--> /home/mara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tray-icon-0.15.1/src/platform_impl/windows/icon.rs:58:8
|
58 | struct RaiiIcon {
| ^^^^^^^^
= note: required for `Arc<tray_icon::platform_impl::platform::icon::RaiiIcon>` to implement `Sync`
note: required because it appears within the type `tray_icon::platform_impl::platform::icon::WinIcon`
--> /home/mara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tray-icon-0.15.1/src/platform_impl/windows/icon.rs:63:19
|
63 | pub(crate) struct WinIcon {
| ^^^^^^^
note: required because it appears within the type `tray_icon::Icon`
--> /home/mara/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tray-icon-0.15.1/src/icon.rs:117:12
|
117 | pub struct Icon {
| ^^^^
note: required by a bound in `check_sync`
--> src/main.rs:1:18
|
1 | fn check_sync<T: Sync>(x: T) -> T {
| ^^^^ required by this bound in `check_sync`
The text was updated successfully, but these errors were encountered:
This happened because the latest windows-sys crate update changed the HICON type from isize to *mut c_void. I think I'd prefer to keep them non sync and require them to be used in the same place as they would be used.
Since 0.15,
tray_icon::Icon
is not Sync anymore on Windows. This is easily visible in the docs for 0.15 vs 0.14. At least on Linux Icon is still Sync which makes for an awkward portability gotcha.Test program:
Compiler error (x86_64-pc-windows-gnu):
The text was updated successfully, but these errors were encountered: