fix(color): memory leak when creating a blank model (#7541)

This commit is contained in:
philmoz
2026-07-23 13:23:52 +10:00
committed by GitHub
parent b706c40046
commit 1b12ee9283
8 changed files with 28 additions and 35 deletions
-1
View File
@@ -1603,7 +1603,6 @@ void edgeTxInit()
#endif // defined(GUI)
#if defined(COLORLCD)
LayoutFactory::deleteCustomScreens();
LayoutFactory::loadCustomScreens();
#endif
@@ -149,6 +149,9 @@ void LayoutFactory::loadDefaultLayout()
//
void LayoutFactory::loadCustomScreens()
{
// Delete old screens
deleteCustomScreens();
unsigned i = 0;
auto viewMain = ViewMain::instance();
@@ -199,10 +199,7 @@ void ScreenSetupPage::build(Window* window)
// Remove this screen from the model
g_model.removeScreenLayout(customScreenIndex);
// Delete all custom screens
LayoutFactory::deleteCustomScreens();
// ... and reload
// Delete and reload custom screens
LayoutFactory::loadCustomScreens();
// adjust index if last screen deleted
@@ -642,6 +642,8 @@ void ModelLabelsWindow::newModel()
luaExecStandalone(path);
}
#endif
} else {
LayoutFactory::loadDefaultLayout();
}
// Main view layout
+1 -3
View File
@@ -127,10 +127,8 @@ HWPots::HWPots(Window* parent) :
potsChanged = false;
setCloseHandler([=]() {
if (potsChanged) {
LayoutFactory::deleteCustomScreens();
if (potsChanged)
LayoutFactory::loadCustomScreens();
}
});
new StaticText(this, {P_NM_X, -PAD_TINY, 0, 0}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
-1
View File
@@ -151,7 +151,6 @@ void applyDefaultTemplate()
g_model.resetScreenData();
LayoutFactory::deleteCustomScreens();
LayoutFactory::deleteTopBarWidgets();
LayoutFactory::loadDefaultLayout();
#endif
// enable switch warnings
+21 -24
View File
@@ -44,7 +44,22 @@ void getModelPath(char * path, const char * filename, const char* pathName)
strcpy(&path[len + 1], filename);
}
void storageEraseAll(bool warn)
static void forceSave()
{
storageDirty(EE_GENERAL);
storageDirty(EE_MODEL);
storageCheck(true);
}
static void storageFormat()
{
sdCheckAndCreateDirectory(RADIO_PATH);
sdCheckAndCreateDirectory(MODELS_PATH);
generalDefault();
setModelDefaults();
}
static void storageEraseAll()
{
TRACE("storageEraseAll");
@@ -60,24 +75,11 @@ void storageEraseAll(bool warn)
g_eeGeneral.blOffBright = 20;
#endif
if (warn) {
ALERT(STR_STORAGE_WARNING, STR_BAD_RADIO_DATA, AU_BAD_RADIODATA);
}
ALERT(STR_STORAGE_WARNING, STR_BAD_RADIO_DATA, AU_BAD_RADIODATA);
RAISE_ALERT(STR_STORAGE_WARNING, STR_STORAGE_FORMAT, STR_PRESS_ANY_KEY_TO_SKIP, AU_NONE);
storageFormat();
storageDirty(EE_GENERAL);
storageDirty(EE_MODEL);
storageCheck(true);
}
void storageFormat()
{
sdCheckAndCreateDirectory(RADIO_PATH);
sdCheckAndCreateDirectory(MODELS_PATH);
generalDefault();
setModelDefaults();
forceSave();
}
void storageCheck(bool immediately)
@@ -166,10 +168,7 @@ const char * createModel()
if (index > 0) {
setModelDefaults(index);
memcpy(g_eeGeneral.currModelFilename, filename, sizeof(g_eeGeneral.currModelFilename));
storageDirty(EE_GENERAL);
storageDirty(EE_MODEL);
storageCheck(true);
forceSave();
}
postModelLoad(false);
@@ -222,12 +221,10 @@ void storageReadAll()
simuCreateDefaultSettings = false;
storageFormat();
g_eeGeneral.chkSum = evalChkSum();
storageDirty(EE_GENERAL);
storageDirty(EE_MODEL);
storageCheck(true);
forceSave();
} else
#endif
storageEraseAll(true);
storageEraseAll();
}
#if !defined(STORAGE_MODELSLIST)
else {
-2
View File
@@ -47,8 +47,6 @@ extern tmr10ms_t rambackupDirtyTime10ms;
//
// Generic storage interface
//
void storageEraseAll(bool warn);
void storageFormat();
void storageReadAll();
void storageCheck(bool immediately);