Skip to content

Commit d6b16fb

Browse files
committed
Guard execution if errored
1 parent bf82df3 commit d6b16fb

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/displayapp/screens/Pawn.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ static void event_handler(lv_obj_t* obj, lv_event_t event) {
4747
AMX* amx = (AMX*) lv_obj_get_user_data(lv_scr_act());
4848
int handler_index = (int) lv_obj_get_user_data(obj);
4949

50+
if (PAWN_INST->is_errored)
51+
return;
52+
5053
amx_Push(amx, event);
5154
int result = amx_Exec(amx, nullptr, handler_index);
5255
if (result != AMX_ERR_NONE) {
@@ -662,6 +665,7 @@ void Pawn::ShowError(unsigned int amx_err) {
662665
}
663666

664667
void Pawn::ShowError(const char* msg) {
668+
is_errored = true;
665669
CleanUI();
666670

667671
lv_obj_t* msglbl = lv_label_create(lv_scr_act(), nullptr);
@@ -687,7 +691,7 @@ void Pawn::QueueError(unsigned int amx_err) {
687691
}
688692

689693
bool Pawn::OnTouchEvent(TouchEvents event) {
690-
if (gesture_index < 0)
694+
if (gesture_index < 0 || is_errored)
691695
return false;
692696

693697
cell ret;
@@ -704,7 +708,7 @@ bool Pawn::OnTouchEvent(TouchEvents event) {
704708
}
705709

706710
bool Pawn::OnTouchEvent(uint16_t x, uint16_t y) {
707-
if (touch_index < 0)
711+
if (touch_index < 0 || is_errored)
708712
return false;
709713

710714
cell ret;

src/displayapp/screens/Pawn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ namespace Pinetime {
9292
amxPool amx_pool;
9393
std::unique_ptr<File> file;
9494

95+
bool is_errored = false;
96+
9597
private:
9698
AMX amx;
9799

0 commit comments

Comments
 (0)