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();
|
detach();
|
||||||
if (lvobj != nullptr) lv_obj_set_parent(lvobj, nullptr);
|
|
||||||
|
|
||||||
if (fieldContainer) {
|
if (fieldContainer) {
|
||||||
lv_obj_scroll_to_y(fieldContainer->getLvObj(), scroll_pos, LV_ANIM_OFF);
|
lv_obj_scroll_to_y(fieldContainer->getLvObj(), scroll_pos, LV_ANIM_OFF);
|
||||||
|
|||||||
+5
-20
@@ -297,7 +297,6 @@ void Window::detach()
|
|||||||
if (parent) {
|
if (parent) {
|
||||||
parent->removeChild(this);
|
parent->removeChild(this);
|
||||||
parent = nullptr;
|
parent = nullptr;
|
||||||
// if (lvobj != nullptr) lv_obj_set_parent(lvobj, nullptr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +324,11 @@ void Window::deleteLater(bool detach, bool trash)
|
|||||||
|
|
||||||
deleteChildren();
|
deleteChildren();
|
||||||
|
|
||||||
|
if (lvobj != nullptr) {
|
||||||
|
lv_obj_del(lvobj);
|
||||||
|
lvobj = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (closeHandler) {
|
if (closeHandler) {
|
||||||
closeHandler();
|
closeHandler();
|
||||||
}
|
}
|
||||||
@@ -339,29 +343,11 @@ void Window::clear()
|
|||||||
invalidate();
|
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()
|
void Window::deleteChildren()
|
||||||
{
|
{
|
||||||
// prevent LVGL refocus while mass-deleting
|
// prevent LVGL refocus while mass-deleting
|
||||||
inhibit_focus = true;
|
inhibit_focus = true;
|
||||||
for (auto window: children) {
|
for (auto window: children) {
|
||||||
window->clearLvgl();
|
|
||||||
window->deleteLater(false);
|
window->deleteLater(false);
|
||||||
}
|
}
|
||||||
inhibit_focus = false;
|
inhibit_focus = false;
|
||||||
@@ -654,7 +640,6 @@ void Window::addChild(Window* window)
|
|||||||
void Window::removeChild(Window* window)
|
void Window::removeChild(Window* window)
|
||||||
{
|
{
|
||||||
children.remove(window);
|
children.remove(window);
|
||||||
if (window->lvobj != nullptr) lv_obj_set_parent(window->lvobj, nullptr);
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-3
@@ -106,9 +106,6 @@ class Window
|
|||||||
void clear();
|
void clear();
|
||||||
virtual void deleteLater(bool detach = true, bool trash = true);
|
virtual void deleteLater(bool detach = true, bool trash = true);
|
||||||
|
|
||||||
void clearLvgl();
|
|
||||||
|
|
||||||
|
|
||||||
bool hasFocus() const
|
bool hasFocus() const
|
||||||
{
|
{
|
||||||
return focusWindow == this;
|
return focusWindow == this;
|
||||||
|
|||||||
Reference in New Issue
Block a user