fix(color): memory leaks in UI code (#6794)
This commit is contained in:
@@ -163,8 +163,6 @@ void FullScreenDialog::deleteLater(bool detach, bool trash)
|
||||
Layer::pop(this);
|
||||
Window::deleteLater(detach, trash);
|
||||
}
|
||||
// Window* p = Layer::back();
|
||||
// if (p) p->show();
|
||||
}
|
||||
|
||||
void FullScreenDialog::setMessage(std::string text)
|
||||
|
||||
@@ -105,7 +105,7 @@ void Page::deleteLater(bool detach, bool trash)
|
||||
Layer::pop(this);
|
||||
Layer::back()->show();
|
||||
|
||||
Window::deleteLater(detach, trash);
|
||||
NavWindow::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
void Page::openMenu()
|
||||
|
||||
@@ -186,6 +186,7 @@ void StaticIcon::deleteLater(bool detach, bool trash)
|
||||
if (_deleted) return;
|
||||
if (mask) free(mask);
|
||||
mask = nullptr;
|
||||
Window::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
void StaticIcon::setColor(LcdColorIndex color)
|
||||
|
||||
@@ -201,7 +201,7 @@ class StaticLZ4Image : public Window
|
||||
protected:
|
||||
uint8_t *imgData = nullptr;
|
||||
|
||||
void deleteLater(bool detach, bool trash) override;
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -324,7 +324,7 @@ void TableField::setAutoEdit()
|
||||
|
||||
void TableField::deleteLater(bool detach, bool trash)
|
||||
{
|
||||
if (!deleted())
|
||||
if (!deleted()) {
|
||||
if (autoedit) {
|
||||
lv_group_t* g = (lv_group_t*)lv_obj_get_group(lvobj);
|
||||
if (g) {
|
||||
@@ -332,4 +332,6 @@ void TableField::deleteLater(bool detach, bool trash)
|
||||
lv_group_set_editing(g, false);
|
||||
}
|
||||
}
|
||||
Window::deleteLater(detach, trash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void ViewMain::deleteLater(bool detach, bool trash)
|
||||
{
|
||||
Layer::pop(this);
|
||||
QuickMenu::shutdownQuickMenu();
|
||||
Window::deleteLater(detach, trash);
|
||||
NavWindow::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
void ViewMain::addMainView(WidgetsContainer* view, uint32_t viewId)
|
||||
|
||||
@@ -84,7 +84,7 @@ class MixLineButton : public InputMixButtonBase
|
||||
void deleteLater(bool detach = true, bool trash = true) override
|
||||
{
|
||||
if (mplex) mplex->deleteLater(detach, trash);
|
||||
ListLineButton::deleteLater(detach, trash);
|
||||
InputMixButtonBase::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
void delayedInit() override
|
||||
|
||||
@@ -35,7 +35,4 @@ class ModelSetupPage: public PageGroupItem {
|
||||
static LAYOUT_VAL_SCALED(BTN_H, 62)
|
||||
static LAYOUT_VAL_SCALED(OPTS_W, 100)
|
||||
static LAYOUT_SIZE_SCALED(NAM_W, 200, 140)
|
||||
|
||||
private:
|
||||
TextButton *labelTextButton = nullptr;
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ void PageGroupHeaderBase:: setTitle(const char* title)
|
||||
|
||||
void PageGroupHeaderBase::setIcon(EdgeTxIcon newIcon)
|
||||
{
|
||||
hdrIcon->setIcon(newIcon);
|
||||
if (hdrIcon) hdrIcon->setIcon(newIcon);
|
||||
}
|
||||
|
||||
void PageGroupHeaderBase::addTab(PageGroupItem* page)
|
||||
@@ -98,6 +98,17 @@ bool PageGroupHeaderBase::hasSubMenu(QuickMenu::SubMenu subMenu)
|
||||
return false;
|
||||
}
|
||||
|
||||
void PageGroupHeaderBase::deleteLater(bool detach, bool trash)
|
||||
{
|
||||
if (deleted()) return;
|
||||
|
||||
for (uint8_t i = 0; i < pages.size(); i += 1)
|
||||
delete pages[i];
|
||||
pages.clear();
|
||||
|
||||
Window::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class PageGroupHeader : public PageGroupHeaderBase
|
||||
@@ -171,7 +182,7 @@ void PageGroupBase::checkEvents()
|
||||
{
|
||||
if (deleted()) return;
|
||||
|
||||
Window::checkEvents();
|
||||
NavWindow::checkEvents();
|
||||
if (currentTab) {
|
||||
currentTab->checkEvents();
|
||||
}
|
||||
@@ -185,7 +196,7 @@ void PageGroupBase::deleteLater(bool detach, bool trash)
|
||||
Layer::pop(this);
|
||||
Layer::back()->show();
|
||||
|
||||
Window::deleteLater(detach, trash);
|
||||
NavWindow::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
void PageGroupBase::onClicked() { Keyboard::hide(false); }
|
||||
|
||||
@@ -124,6 +124,8 @@ class PageGroupHeaderBase : public Window
|
||||
bool isCurrent(uint8_t idx) const { return currentIndex == idx; }
|
||||
uint8_t tabCount() const { return pages.size(); }
|
||||
|
||||
void deleteLater(bool detach = true, bool trash = true) override;
|
||||
|
||||
protected:
|
||||
uint8_t currentIndex = 0;
|
||||
lv_obj_t* titleLabel = nullptr;
|
||||
|
||||
@@ -252,7 +252,7 @@ void QuickMenu::deleteLater(bool detach, bool trash)
|
||||
|
||||
instance = nullptr;
|
||||
|
||||
Window::deleteLater(detach, trash);
|
||||
NavWindow::deleteLater(detach, trash);
|
||||
}
|
||||
|
||||
void QuickMenu::openQM(std::function<void()> cancelHandler,
|
||||
|
||||
@@ -556,7 +556,8 @@ HeaderIcon::HeaderIcon(Window* parent, const char* iconFile, std::function<void(
|
||||
StaticIcon(parent, 0, 0, ICON_TOPLEFT_BG, COLOR_THEME_FOCUS_INDEX),
|
||||
action(std::move(action))
|
||||
{
|
||||
(new StaticIcon(this, 0, 0, iconFile, COLOR_THEME_PRIMARY2_INDEX))->center(width(), height());
|
||||
this->icon = new StaticIcon(this, 0, 0, iconFile, COLOR_THEME_PRIMARY2_INDEX);
|
||||
this->icon->center(width(), height());
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
if (this->action) {
|
||||
lv_obj_add_flag(lvobj, LV_OBJ_FLAG_CLICKABLE);
|
||||
|
||||
@@ -183,7 +183,7 @@ class HeaderIcon : public StaticIcon
|
||||
HeaderIcon(Window *parent, EdgeTxIcon icon, std::function<void()> action = nullptr);
|
||||
HeaderIcon(Window *parent, const char* iconFile, std::function<void()> action = nullptr);
|
||||
|
||||
void setIcon(EdgeTxIcon newIcon) { icon->setIcon(newIcon); }
|
||||
void setIcon(EdgeTxIcon newIcon) { if (icon) icon->setIcon(newIcon); }
|
||||
|
||||
protected:
|
||||
std::function<void()> action;
|
||||
|
||||
Reference in New Issue
Block a user