mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-20 12:25:06 +00:00
Fix for crash
This commit is contained in:
parent
761927ceda
commit
87215baf55
@ -6,6 +6,7 @@ Two kernel modules cover LVGL:
|
|||||||
|
|
||||||
- **`lvgl-module`** (`Modules/lvgl-module/`, `<lvgl/*.h>`) owns LVGL's lifecycle: init/deinit, the LVGL task loop, and `lvgl_lock()`/`lvgl_try_lock()`/`lvgl_unlock()` mutex-based locking that any task must hold before touching LVGL objects. It bridges Tactility's device model to LVGL indevs (`lvgl/devices/*.h`: `display`, `pointer`, `keyboard`, `trackball`), and provides shared fonts (`lvgl/fonts.h`: Montserrat text sizes, Material Symbols icon sets for statusbar/launcher/shared use) and a few shared widgets (`lvgl/widgets/*.h`: `toolbar`, `spinner`, `sliderbox`).
|
- **`lvgl-module`** (`Modules/lvgl-module/`, `<lvgl/*.h>`) owns LVGL's lifecycle: init/deinit, the LVGL task loop, and `lvgl_lock()`/`lvgl_try_lock()`/`lvgl_unlock()` mutex-based locking that any task must hold before touching LVGL objects. It bridges Tactility's device model to LVGL indevs (`lvgl/devices/*.h`: `display`, `pointer`, `keyboard`, `trackball`), and provides shared fonts (`lvgl/fonts.h`: Montserrat text sizes, Material Symbols icon sets for statusbar/launcher/shared use) and a few shared widgets (`lvgl/widgets/*.h`: `toolbar`, `spinner`, `sliderbox`).
|
||||||
- **`lvgl-window-manager-module`** (`Modules/lvgl-window-manager-module/`, `<lvgl_window_manager/*.h>`) manages a single stacked window per app instance on top of `lvgl-module`. `window_manager_start()`/`window_manager_stop()` create/tear down the root widget (plus optional chrome from a configured `WindowManagerScreenInitFn`); `window_manager_create()`/`window_manager_remove()` push/pop an app's window and (re)populate it via a `WindowCreateWidgetsFn`. Only the topmost window ever has live widgets - burying and resurfacing a window deletes and rebuilds its widget tree rather than hiding/showing it. That rebuild-on-remove path can run `create_widgets` on a *different* app's thread (whichever app's `window_manager_remove()` call caused this window to resurface), so `create_widgets` must only rebuild already-committed state, never decide what happens next - state transitions belong in the app's own `main()` event loop, driven by real `APP_EVENT_RESULT`s.
|
- **`lvgl-window-manager-module`** (`Modules/lvgl-window-manager-module/`, `<lvgl_window_manager/*.h>`) manages a single stacked window per app instance on top of `lvgl-module`. `window_manager_start()`/`window_manager_stop()` create/tear down the root widget (plus optional chrome from a configured `WindowManagerScreenInitFn`); `window_manager_create()`/`window_manager_remove()` push/pop an app's window and (re)populate it via a `WindowCreateWidgetsFn`. Only the topmost window ever has live widgets - burying and resurfacing a window deletes and rebuilds its widget tree rather than hiding/showing it. That rebuild-on-remove path can run `create_widgets` on a *different* app's thread (whichever app's `window_manager_remove()` call caused this window to resurface), so `create_widgets` must only rebuild already-committed state, never decide what happens next - state transitions belong in the app's own `main()` event loop, driven by real `APP_EVENT_RESULT`s.
|
||||||
|
Widget pointers an app keeps become dangling once its window is buried (e.g. by a dialog it started). Use `window_manager_create_ext()` with a `destroy_widgets` callback that clears them, and skip widget updates from the app's own thread while they're cleared.
|
||||||
|
|
||||||
## Keyboard navigation
|
## Keyboard navigation
|
||||||
|
|
||||||
|
|||||||
@ -136,6 +136,10 @@ void onOperationEvent(Context* ctx, const AppHubEvent& event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateViews(Context* ctx) {
|
void updateViews(Context* ctx) {
|
||||||
|
// Covered by another window (e.g. a dialog): createWidgets() updates the views when it's shown again
|
||||||
|
if (ctx->toolbar == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
lvgl_toolbar_clear_actions(ctx->toolbar);
|
lvgl_toolbar_clear_actions(ctx->toolbar);
|
||||||
ctx->spinner = lvgl_toolbar_add_spinner_action(ctx->toolbar);
|
ctx->spinner = lvgl_toolbar_add_spinner_action(ctx->toolbar);
|
||||||
lv_obj_set_hidden(ctx->updateLabel, true);
|
lv_obj_set_hidden(ctx->updateLabel, true);
|
||||||
@ -200,6 +204,14 @@ void createWidgets(lv_obj_t* parent, void* userData) {
|
|||||||
updateViews(ctx);
|
updateViews(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroyWidgets(void* userData) {
|
||||||
|
auto* ctx = static_cast<Context*>(userData);
|
||||||
|
ctx->toolbar = nullptr;
|
||||||
|
ctx->spinner = nullptr;
|
||||||
|
ctx->updateButton = nullptr;
|
||||||
|
ctx->updateLabel = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t appMain(int argc, char* argv[]) {
|
int32_t appMain(int argc, char* argv[]) {
|
||||||
uint32_t appInstanceId = app_scheduler_current_app_id();
|
uint32_t appInstanceId = app_scheduler_current_app_id();
|
||||||
// argv layout: [0]=appId
|
// argv layout: [0]=appId
|
||||||
@ -218,7 +230,7 @@ int32_t appMain(int argc, char* argv[]) {
|
|||||||
check(app_event_subscribe(&sub, &event_group) == ERROR_NONE);
|
check(app_event_subscribe(&sub, &event_group) == ERROR_NONE);
|
||||||
check(app_hub_event_subscribe(&ctx.appHubSub, &event_group) == ERROR_NONE);
|
check(app_hub_event_subscribe(&ctx.appHubSub, &event_group) == ERROR_NONE);
|
||||||
|
|
||||||
WindowId window = window_manager_create(appInstanceId, createWidgets, &ctx);
|
WindowId window = window_manager_create_ext(appInstanceId, createWidgets, destroyWidgets, &ctx);
|
||||||
|
|
||||||
bool shouldClose = false;
|
bool shouldClose = false;
|
||||||
while (!shouldClose) {
|
while (!shouldClose) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user