@@ -77,7 +77,7 @@ void PlatformBackend::executeLvTaskHandler() noexcept
7777} // namespace Graphics
7878#endif
7979
80- #if defined USE_WINSDL_BACKEND
80+ #if defined USE_SDL_BACKEND
8181
8282#include < chrono>
8383#include < thread>
@@ -92,7 +92,10 @@ void PlatformBackend::executeLvTaskHandler() noexcept
9292namespace Graphics
9393{
9494
95- PlatformBackend::PlatformBackend () noexcept = default ;
95+ PlatformBackend::PlatformBackend () noexcept
96+ {
97+ m_isTickThreadRunning.store (false );
98+ };
9699
97100void PlatformBackend::platformDependentInit (lv_disp_drv_t * _displayDriver) noexcept
98101{
@@ -102,14 +105,6 @@ void PlatformBackend::platformDependentInit(lv_disp_drv_t* _displayDriver) noexc
102105
103106void PlatformBackend::initPlatformGfxTimer () noexcept
104107{
105- m_tickThread = std::thread ([] {
106- while (true )
107- {
108- lv_tick_inc (LvglNotificationTime);
109- std::this_thread::sleep_for (std::chrono::milliseconds (LvglNotificationTime));
110- }
111- });
112- m_tickThread.detach ();
113108 indevPlatformInit ();
114109 lv_indev_drv_init (&m_indevDriver);
115110}
@@ -144,6 +139,18 @@ void PlatformBackend::memoryMonitor(lv_timer_t* _param) noexcept
144139
145140void PlatformBackend::executeLvTaskHandler () noexcept
146141{
142+ if (!m_isTickThreadRunning)
143+ {
144+ m_isTickThreadRunning = true ;
145+ m_tickThread = std::thread ([this ] {
146+ while (m_isTickThreadRunning)
147+ {
148+ lv_tick_inc (LvglNotificationTime);
149+ std::this_thread::sleep_for (std::chrono::milliseconds (LvglNotificationTime));
150+ }
151+ });
152+ m_tickThread.detach ();
153+ }
147154 lv_task_handler ();
148155 std::this_thread::sleep_for (std::chrono::milliseconds (LvglNotificationTime));
149156}
0 commit comments