From c1a809c567a3f64c478c8e6c495552357864b1c2 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 7 Aug 2023 14:19:38 +0200 Subject: [PATCH] ui/lvgl: fix a bug where a top container didn't have its object created a previous commit 7d1ab5cb rewrote toplayer objects creation as Container.newTop except the new code was using the top layer object obtained from lv_disp_get_layer_top as is. this obviously led to all sorts of UB and illegal memory access when screen.sleep'ing. --- src/ui/lvgl.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/lvgl.zig b/src/ui/lvgl.zig index 9fcd2dd..da441ad 100644 --- a/src/ui/lvgl.zig +++ b/src/ui/lvgl.zig @@ -482,7 +482,8 @@ pub const Container = struct { /// suitable for widgets like a popup window. pub fn newTop() !Container { const toplayer = lv_disp_get_layer_top(null); - return .{ .lvobj = toplayer }; + const o = lv_obj_create(toplayer) orelse return error.OutOfMemory; + return .{ .lvobj = o }; } /// applies flex layout to the container.