From 49aa58446bad367a627ca77bc59457ba16b82571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 3 Dec 2019 17:45:48 +0100 Subject: [PATCH] [python] modkandinsky: fill_rect and draw_string calls might take some time. As "micropython_port_vm_hook_loop" is not called while we are executing module code, we add an extra check for user interruption in module functions. --- python/port/mod/kandinsky/modkandinsky.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index eacc184ae..408292db5 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -70,6 +70,10 @@ mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t * args) { KDColor backgroundColor = (n_args >= 5) ? ColorForTuple(args[4]) : KDColorWhite; MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); KDIonContext::sharedContext()->drawString(text, point, KDFont::LargeFont, textColor, backgroundColor); + /* drawString function might take some time to execute so we add an extra check + * for user interruption (to avoid freezing in an infinite loop calling + * 'drawString' for instance). */ + micropython_port_interrupt_if_needed(); return mp_const_none; } @@ -83,5 +87,9 @@ mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t * args) { KDColor color = ColorForTuple(args[4]); MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); KDIonContext::sharedContext()->fillRect(rect, color); + /* fillRect function might take some time to execute so we add an extra check + * for user interruption (to avoid freezing in an infinite loop calling + * 'fillRect' for instance). */ + micropython_port_interrupt_if_needed(); return mp_const_none; }