Fix crash when using experimental C++ SkiaRenderer API

Don't box the Result<Renderer, Error>, but box just the renderer.
Otherwhise the cast to the renderer pointer is nonsense.
This commit is contained in:
Simon Hausmann 2023-05-17 14:21:39 +02:00
parent 975e82bfbb
commit d9bc7a08f9

View file

@ -274,12 +274,16 @@ pub unsafe extern "C" fn slint_skia_renderer_new(
let window_adapter =
core::mem::transmute::<&WindowAdapterRcOpaque, &Rc<dyn WindowAdapter>>(window_adapter);
let weak = Rc::downgrade(window_adapter);
Box::into_raw(Box::new(SkiaRenderer::new(
let boxed_renderer: Box<SkiaRenderer> = Box::new(
SkiaRenderer::new(
weak,
&*(handle_opaque as *const CppRawHandle),
&*(handle_opaque as *const CppRawHandle),
PhysicalSize { width: size.width, height: size.height },
))) as SkiaRendererOpaque
)
.unwrap(),
);
Box::into_raw(boxed_renderer) as SkiaRendererOpaque
}
#[no_mangle]