window: prevent focus events while mass-deleting

This commit is contained in:
Raphael Coeffic
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent bc793651f4
commit ad658a92a4
+5
View File
@@ -29,6 +29,7 @@ std::list<Window *> Window::trash;
extern lv_obj_t *virtual_kb;
static bool is_scrolling = false;
static bool inhibit_focus = false;
static void window_event_cb(lv_event_t * e)
{
@@ -136,6 +137,7 @@ static void window_event_cb(lv_event_t * e)
window->setScrollPositionX(scroll_x);
} else if (code == LV_EVENT_FOCUSED) {
if (inhibit_focus) return;
bool focused = ((Window *)target->user_data)->hasFocus();
TRACE_WINDOWS("FOCUSED[%d] %s", focused,
window->getWindowDebugString().c_str());
@@ -307,10 +309,13 @@ void Window::clearLvgl()
void Window::deleteChildren()
{
// prevent LVGL refocus while mass-deleting
inhibit_focus = true;
for (auto window: children) {
window->clearLvgl();
window->deleteLater(false);
}
inhibit_focus = false;
children.clear();
}