diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-28 15:34:11 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-28 15:34:11 +1000 |
| commit | 984b874d7e53980f96fb1581f32d771f78cb91ab (patch) | |
| tree | ec6c171d303a2ccb16cb15ead2249073d56954f3 /src/tangara/ui/ui_fsm.cpp | |
| parent | 9204b585aedd35f85d3c9118299459d3586cf499 (diff) | |
| download | tangara-fw-984b874d7e53980f96fb1581f32d771f78cb91ab.tar.gz | |
Fix some issues with the splash screen
- fix a use-after-free involving the alerts container that was
happening when showing the first screen
- fix some issues where the splash screen wouldn't come up as early as
it needs to when another bootup task was making heavy use of the spi
bus
Diffstat (limited to 'src/tangara/ui/ui_fsm.cpp')
| -rw-r--r-- | src/tangara/ui/ui_fsm.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index 968e2931..7c4147a3 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -294,7 +294,7 @@ void UiState::react(const internal::InitDisplay& ev) { drivers::displays::InitialisationData init_data = drivers::displays::kST7735R; // HACK: correct the display size for our prototypes. - // nvs.DisplaySize({161, 130}); + // ev.nvs.DisplaySize({161, 130}); auto actual_size = ev.nvs.DisplaySize(); init_data.width = actual_size.first.value_or(init_data.width); @@ -307,12 +307,14 @@ void UiState::react(const internal::InitDisplay& ev) { sDisplay->SetDisplayOn(!ev.gpios.IsLocked()); } -void UiState::PushScreen(std::shared_ptr<Screen> screen) { +void UiState::PushScreen(std::shared_ptr<Screen> screen, bool replace) { lv_obj_set_parent(sAlertContainer, screen->alert()); if (sCurrentScreen) { sCurrentScreen->onHidden(); - sScreens.push(sCurrentScreen); + if (!replace) { + sScreens.push(sCurrentScreen); + } } sCurrentScreen = screen; sCurrentScreen->onShown(); @@ -568,7 +570,7 @@ void Lua::entry() { registry.AddPropertyModule( "backstack", { - {"push", [&](lua_State* s) { return PushLuaScreen(s); }}, + {"push", [&](lua_State* s) { return PushLuaScreen(s, false); }}, {"pop", [&](lua_State* s) { return PopLuaScreen(s); }}, {"reset", [&](lua_State* s) { return ResetLuaScreen(s); }}, }); @@ -603,7 +605,6 @@ void Lua::entry() { sBluetoothConnected.setDirect(bt.IsConnected()); sBluetoothDevices.setDirect(bt.KnownDevices()); - sCurrentScreen.reset(); if (sServices->sd() == drivers::SdState::kMounted) { sLua->RunScript("/sdcard/config.lua"); } @@ -611,7 +612,7 @@ void Lua::entry() { } } -auto Lua::PushLuaScreen(lua_State* s) -> int { +auto Lua::PushLuaScreen(lua_State* s, bool replace) -> int { // Ensure the arg looks right before continuing. luaL_checktype(s, 1, LUA_TTABLE); @@ -641,7 +642,7 @@ auto Lua::PushLuaScreen(lua_State* s) -> int { // Finally, push the now-initialised screen as if it were a regular C++ // screen. - PushScreen(new_screen); + PushScreen(new_screen, replace); return 0; } @@ -662,12 +663,11 @@ auto Lua::ResetLuaScreen(lua_State* s) -> int { ESP_LOGW(kTag, "ignoring reset as popping is blocked"); return 0; } - sCurrentScreen->onHidden(); } while (!sScreens.empty()) { sScreens.pop(); } - return PushLuaScreen(s); + return PushLuaScreen(s, true); } auto Lua::QueueNext(lua_State*) -> int { |
