slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.12k stars 578 forks source link

Revert workaround for rgb breakage before release #5574

Closed tronical closed 2 months ago

tronical commented 3 months ago

Commit 402f7ea64913514712c1b71be67e3e2e12982f19 works around https://github.com/kornelski/rust-rgb/issues/116 . We need to revert that before the release once this is resolved upstream.

rgb is re-exported in our API.

andyTsing commented 3 months ago
Today, the code that was able to run before suddenly showed the following error: Running cargo build --bin=TX-RPAService --package=TX-RPAService --message-format=json... Compiling i-slint-core v1.6.0 Compiling TX-RPAService v0.1.0 (D:\Share\TXRPAService) Compiling windows v0.58.0 Compiling tray-icon v0.14.3 error[E0599]: the method as_bytes exists for reference &SharedPixelBuffer<Rgb<u8>>, but its trait bounds were not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image\cache.rs:18:59 18 SharedImageBuffer::RGB8(pixels) => pixels.as_bytes().len(), ^^^^^^^^ method cannot be called on &SharedPixelBuffer<Rgb<u8>> due to unsatisfied trait bounds
note: trait bound [RGB<u8>]: ComponentBytes<u8> was not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 92 impl<Pixel: Clone + rgb::Pod> SharedPixelBuffer
93 where
94 [Pixel]: rgb::ComponentBytes,
^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here

= help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item as_bytes, perhaps you need to implement one of them: candidate #1: ComponentBytes candidate #2: EncodableLayout candidate #3: zerocopy::AsBytes

error[E0599]: the method as_bytes exists for reference &SharedPixelBuffer<Rgba<u8>>, but its trait bounds were not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image\cache.rs:19:60 19 SharedImageBuffer::RGBA8(pixels) => pixels.as_bytes().len(), ^^^^^^^^ method cannot be called on &SharedPixelBuffer<Rgba<u8>> due to unsatisfied trait bounds
note: trait bound [RGBA<u8>]: ComponentBytes<u8> was not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 92 impl<Pixel: Clone + rgb::Pod> SharedPixelBuffer
93 where
94 [Pixel]: rgb::ComponentBytes,
^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here

= help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item as_bytes, perhaps you need to implement one of them: candidate #1: ComponentBytes candidate #2: EncodableLayout candidate #3: zerocopy::AsBytes

error[E0599]: the method as_bytes exists for reference &SharedPixelBuffer<Rgba<u8>>, but its trait bounds were not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image\cache.rs:20:73 20 SharedImageBuffer::RGBA8Premultiplied(pixels) => pixels.as_bytes().len(), ^^^^^^^^ method cannot be called on &SharedPixelBuffer<Rgba<u8>> due to unsatisfied trait bounds
note: trait bound [RGBA<u8>]: ComponentBytes<u8> was not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 92 impl<Pixel: Clone + rgb::Pod> SharedPixelBuffer
93 where
94 [Pixel]: rgb::ComponentBytes,
^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here

= help: items from traits can only be used if the trait is implemented and in scope = note: the following traits define an item as_bytes, perhaps you need to implement one of them: candidate #1: ComponentBytes candidate #2: EncodableLayout candidate #3: zerocopy::AsBytes

error[E0308]: mismatched types --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image\svg.rs:75:50 68 buffer.make_mut_bytes(), ------ here the type of buffer is inferred to be graphics::image::SharedPixelBuffer<u8> ... 75 Ok(SharedImageBuffer::RGBA8Premultiplied(buffer)) ------------------------------------- ^^^^^^ expected SharedPixelBuffer<Rgba<u8>>, found SharedPixelBuffer<u8>
arguments to this enum variant are incorrect
= note: expected struct `graphics::image::SharedPixelBuffer<RGBA<u8>>`
           found struct `graphics::image::SharedPixelBuffer<u8>`

note: tuple variant defined here --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:173:5 | 173 | RGBA8Premultiplied(SharedPixelBuffer), | ^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound [RGBA<u8>]: ComponentBytes<u8> is not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image\svg.rs:68:20 68 buffer.make_mut_bytes(), ^^^^^^^^^^^^^^ the trait ComponentBytes<u8> is not implemented for [RGBA<u8>]
= help: the trait `ComponentBytes<RGBA<u8>>` is implemented for `[RGBA<u8>]`
= help: for that trait implementation, expected `RGBA<u8>`, found `u8`

note: required by a bound in graphics::image::SharedPixelBuffer::<Pixel>::make_mut_bytes --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 | 94 | [Pixel]: rgb::ComponentBytes, | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in SharedPixelBuffer::<Pixel>::make_mut_bytes ... 103 | pub fn make_mut_bytes(&mut self) -> &mut [u8] { | -------------- required by a bound in this associated function

error[E0599]: the method as_bytes exists for reference &SharedPixelBuffer<Rgb<u8>>, but its trait bounds were not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\software_renderer.rs:1247:26 1247 data: &b.as_bytes()[start 3..end 3], ^^^^^^^^ method cannot be called on &SharedPixelBuffer<Rgb<u8>> due to unsatisfied trait bounds
note: trait bound [RGB<u8>]: ComponentBytes<u8> was not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 92 impl<Pixel: Clone + rgb::Pod> SharedPixelBuffer
93 where
94 [Pixel]: rgb::ComponentBytes,
^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
 = help: items from traits can only be used if the trait is implemented and in scope
 = note: the following traits define an item `as_bytes`, perhaps you need to implement one of them:
         candidate #1: `ComponentBytes`
         candidate #2: `EncodableLayout`
         candidate #3: `zerocopy::AsBytes`
error[E0599]: the method as_bytes exists for reference &SharedPixelBuffer<Rgba<u8>>, but its trait bounds were not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\software_renderer.rs:1253:26 1253 data: &b.as_bytes()[start 4..end 4], ^^^^^^^^ method cannot be called on &SharedPixelBuffer<Rgba<u8>> due to unsatisfied trait bounds
note: trait bound [RGBA<u8>]: ComponentBytes<u8> was not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 92 impl<Pixel: Clone + rgb::Pod> SharedPixelBuffer
93 where
94 [Pixel]: rgb::ComponentBytes,
^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
 = help: items from traits can only be used if the trait is implemented and in scope
 = note: the following traits define an item `as_bytes`, perhaps you need to implement one of them:
         candidate #1: `ComponentBytes`
         candidate #2: `EncodableLayout`
         candidate #3: `zerocopy::AsBytes`
error[E0599]: the method as_bytes exists for reference &SharedPixelBuffer<Rgba<u8>>, but its trait bounds were not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\software_renderer.rs:1260:30 1260 data: &b.as_bytes()[start 4..end 4], ^^^^^^^^ method cannot be called on &SharedPixelBuffer<Rgba<u8>> due to unsatisfied trait bounds
note: trait bound [RGBA<u8>]: ComponentBytes<u8> was not satisfied --> C:\Users\andy_.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-core-1.6.0\graphics\image.rs:94:14 92 impl<Pixel: Clone + rgb::Pod> SharedPixelBuffer
93 where
94 [Pixel]: rgb::ComponentBytes,
^^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound introduced here
 = help: items from traits can only be used if the trait is implemented and in scope
 = note: the following traits define an item `as_bytes`, perhaps you need to implement one of them:
         candidate #1: `ComponentBytes`
         candidate #2: `EncodableLayout`
         candidate #3: `zerocopy::AsBytes`

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0277, E0308, E0599. For more information about an error, try rustc --explain E0277. error: could not compile i-slint-core (lib) due to 9 previous errors warning: build failed, waiting for other jobs to finish... Error: Cargo invocation failed. at t.Cargo.getCargoArtifacts (c:\Users\andy_.vscode\extensions\vadimcn.vscode-lldb-1.10.0\extension.js:1:14943) at process.processTicksAndRejections (node:internal/process/taskqueues:95:5) at async Object.open (c:\Users\andy.vscode\extensions\vadimcn.vscode-lldb-1.10.0\extension.js:1:13253) Caused by: Error: exit code: 101. at ChildProcess. (c:\Users\andy_.vscode\extensions\vadimcn.vscode-lldb-1.10.0\extension.js:1:16610) at ChildProcess.emit (node:events:514:28) at ChildProcess.emit (node:domain:488:12) at maybeClose (node:internal/child_process:1105:16) at ChildProcess._handle.onexit (node:internal/child_process:305:5)

tronical commented 2 months ago

This is fixed upstream with the latest rgb crate version 0.8.44. Please run cargo update once and the issue will go away. In Slint git master branch we've backed out the workaround in commit e74745c68a9bbdd6eb4e68633cb68ea18aa48d9d .