simplify LVGL object removal
Fixes as well some issues with widgets being displayed after libopenui object has been deleted.
This commit is contained in:
committed by
Raphael Coeffic
parent
c7da6b2796
commit
d71ad73eb1
@@ -54,7 +54,6 @@ void Keyboard::clearField()
|
||||
}
|
||||
|
||||
detach();
|
||||
if (lvobj != nullptr) lv_obj_set_parent(lvobj, nullptr);
|
||||
|
||||
if (fieldContainer) {
|
||||
lv_obj_scroll_to_y(fieldContainer->getLvObj(), scroll_pos, LV_ANIM_OFF);
|
||||
|
||||
+5
-20
@@ -297,7 +297,6 @@ void Window::detach()
|
||||
if (parent) {
|
||||
parent->removeChild(this);
|
||||
parent = nullptr;
|
||||
// if (lvobj != nullptr) lv_obj_set_parent(lvobj, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,6 +324,11 @@ void Window::deleteLater(bool detach, bool trash)
|
||||
|
||||
deleteChildren();
|
||||
|
||||
if (lvobj != nullptr) {
|
||||
lv_obj_del(lvobj);
|
||||
lvobj = nullptr;
|
||||
}
|
||||
|
||||
if (closeHandler) {
|
||||
closeHandler();
|
||||
}
|
||||
@@ -339,29 +343,11 @@ void Window::clear()
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Window::clearLvgl()
|
||||
{
|
||||
if(lvobj == nullptr)
|
||||
return;
|
||||
|
||||
for (auto window: children)
|
||||
{
|
||||
if(window->lvobj != nullptr && window->lvobj->parent == lvobj)
|
||||
window->clearLvgl();
|
||||
}
|
||||
|
||||
lv_obj_remove_event_cb(lvobj, window_event_cb);
|
||||
lv_obj_set_user_data(lvobj, nullptr);
|
||||
lv_group_remove_obj(lvobj);
|
||||
lvobj = nullptr;
|
||||
}
|
||||
|
||||
void Window::deleteChildren()
|
||||
{
|
||||
// prevent LVGL refocus while mass-deleting
|
||||
inhibit_focus = true;
|
||||
for (auto window: children) {
|
||||
window->clearLvgl();
|
||||
window->deleteLater(false);
|
||||
}
|
||||
inhibit_focus = false;
|
||||
@@ -654,7 +640,6 @@ void Window::addChild(Window* window)
|
||||
void Window::removeChild(Window* window)
|
||||
{
|
||||
children.remove(window);
|
||||
if (window->lvobj != nullptr) lv_obj_set_parent(window->lvobj, nullptr);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
|
||||
-3
@@ -106,9 +106,6 @@ class Window
|
||||
void clear();
|
||||
virtual void deleteLater(bool detach = true, bool trash = true);
|
||||
|
||||
void clearLvgl();
|
||||
|
||||
|
||||
bool hasFocus() const
|
||||
{
|
||||
return focusWindow == this;
|
||||
|
||||
Reference in New Issue
Block a user