mirror of
https://github.com/ALLFATHER-BV/wadamesh.git
synced 2026-09-26 11:37:56 +00:00
The SDK documented building widgets in on_open() and gave no way to take them down, so an app with a second screen drew it on top of the first. pisti87 hit this building a multi-screen app and had been working around it with buttons; he also noted that ui.list() has clear() while the page it sits on does not. The reason this is not just lv_obj_clean() is the handles. WidgetUd holds a raw lv_obj_t*, guarded only by `if (u->obj)`, so a Lua variable still referring to a label from the screen just cleared would sail past that check into freed memory. Every handle now records the generation it was created in, clear() bumps the generation, and the accessors null the pointer of any handle from an older one. The null guard that every method already has then turns a stale call into a no-op. Given the day this codebase has had with use-after-frees, a clear() that invited one would not have been worth shipping. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>