Further simplify renderer storage in C++ platform API

Using an std::optional is even simpler and avoids a malloc.
This commit is contained in:
Simon Hausmann 2023-05-17 18:24:23 +02:00 committed by Simon Hausmann
parent b47936d4cd
commit ef4074b041
3 changed files with 10 additions and 14 deletions

View file

@ -55,9 +55,7 @@ private:
cbindgen_private::slint_window_adapter_new(
this, [](void *wa) { delete reinterpret_cast<const WindowAdapter *>(wa); },
[](void *wa) {
return reinterpret_cast<const WindowAdapter *>(wa)
->renderer()
.renderer_handle();
return reinterpret_cast<WindowAdapter *>(wa)->renderer().renderer_handle();
},
[](void *wa) { reinterpret_cast<const WindowAdapter *>(wa)->show(); },
[](void *wa) { reinterpret_cast<const WindowAdapter *>(wa)->hide(); },
@ -97,7 +95,7 @@ public:
/// Re-implement this function to provide a reference to the renderer for use with the window
/// adapter.
virtual AbstractRenderer &renderer() const = 0;
virtual AbstractRenderer &renderer() = 0;
/// Return the slint::Window associated with this window.
///