File tree Expand file tree Collapse file tree
lib/3rd_party_adapters/LVGL Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22#include < math.h>
33#include < stack>
44
5- static std::stack<IScreen * > screenHistory;
5+ static std::stack<std::shared_ptr< IScreen> > screenHistory;
66
77static inline void IScreen_leave ()
88{
@@ -12,8 +12,6 @@ static inline void IScreen_leave()
1212 // clear the current screen of lvgl
1313 lv_obj_clean (lv_scr_act ());
1414
15- // free up the memory of current screen
16- delete screenHistory.top ();
1715 // remove current screen
1816 screenHistory.pop ();
1917 // draw previous screen
@@ -257,7 +255,7 @@ void ScreenMenu::draw()
257255 lv_scr_load (screen);
258256
259257 /* add the screen to the screens history list */
260- screenHistory.push (this );
258+ screenHistory.push (shared_from_this () );
261259}
262260
263261/* *
@@ -468,5 +466,5 @@ void ScreenValueModifier::draw()
468466 lv_scr_load (screen);
469467
470468 /* add the screen to the screens history list */
471- screenHistory.push (this );
469+ screenHistory.push (shared_from_this () );
472470}
Original file line number Diff line number Diff line change 55#pragma once
66
77#include < lvgl.h>
8+ #include < memory>
89#include < user_interaction/MenuItem.hpp>
910
1011/* *
@@ -25,7 +26,7 @@ class IScreen
2526 * it receives a list of menu items for it's topology
2627 *
2728 */
28- class ScreenMenu final : public IScreen
29+ class ScreenMenu final : public IScreen, std::enable_shared_from_this<ScreenMenu>
2930{
3031 public:
3132 ScreenMenu (MenuItemList itemList);
@@ -41,7 +42,7 @@ class ScreenMenu final : public IScreen
4142 * @brief Screen for value modification
4243 *
4344 */
44- class ScreenValueModifier final : public IScreen
45+ class ScreenValueModifier final : public IScreen, std::enable_shared_from_this<ScreenValueModifier>
4546{
4647 public:
4748 ScreenValueModifier (const MenuItemValue *const menuItem);
You can’t perform that action at this time.
0 commit comments