Tile event handler : read the event data only if the event is a "value changed event". LVGL sends many other event and some of them do not set the event data (global static variable) to a valid address, which may cause an invalid read. I noticed that when porting this class on RISC-V platform (BL602).
This commit is contained in:
parent
7b75ca591d
commit
514481ef7f
|
@ -6,15 +6,17 @@ using namespace Pinetime::Applications::Screens;
|
|||
|
||||
namespace {
|
||||
static void lv_update_task(struct _lv_task_t* task) {
|
||||
auto user_data = static_cast<Tile*>(task->user_data);
|
||||
auto* user_data = static_cast<Tile*>(task->user_data);
|
||||
user_data->UpdateScreen();
|
||||
}
|
||||
|
||||
static void event_handler(lv_obj_t* obj, lv_event_t event) {
|
||||
if (event != LV_EVENT_VALUE_CHANGED) return;
|
||||
|
||||
Tile* screen = static_cast<Tile*>(obj->user_data);
|
||||
uint32_t* eventDataPtr = (uint32_t*) lv_event_get_data();
|
||||
auto* eventDataPtr = (uint32_t*) lv_event_get_data();
|
||||
uint32_t eventData = *eventDataPtr;
|
||||
screen->OnObjectEvent(obj, event, eventData);
|
||||
screen->OnValueChangedEvent(obj, eventData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,9 +126,9 @@ bool Tile::Refresh() {
|
|||
return running;
|
||||
}
|
||||
|
||||
void Tile::OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId) {
|
||||
if (event == LV_EVENT_VALUE_CHANGED) {
|
||||
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
|
||||
running = false;
|
||||
}
|
||||
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
|
||||
if(obj != btnm1) return;
|
||||
|
||||
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
|
||||
running = false;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Pinetime {
|
|||
|
||||
bool Refresh() override;
|
||||
void UpdateScreen();
|
||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event, uint32_t buttonId);
|
||||
void OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId);
|
||||
|
||||
private:
|
||||
Pinetime::Controllers::Battery& batteryController;
|
||||
|
|
Loading…
Reference in a new issue