fix(color): memory leak when creating a blank model (#7541)
This commit is contained in:
@@ -1603,7 +1603,6 @@ void edgeTxInit()
|
|||||||
#endif // defined(GUI)
|
#endif // defined(GUI)
|
||||||
|
|
||||||
#if defined(COLORLCD)
|
#if defined(COLORLCD)
|
||||||
LayoutFactory::deleteCustomScreens();
|
|
||||||
LayoutFactory::loadCustomScreens();
|
LayoutFactory::loadCustomScreens();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,9 @@ void LayoutFactory::loadDefaultLayout()
|
|||||||
//
|
//
|
||||||
void LayoutFactory::loadCustomScreens()
|
void LayoutFactory::loadCustomScreens()
|
||||||
{
|
{
|
||||||
|
// Delete old screens
|
||||||
|
deleteCustomScreens();
|
||||||
|
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
auto viewMain = ViewMain::instance();
|
auto viewMain = ViewMain::instance();
|
||||||
|
|
||||||
|
|||||||
@@ -199,10 +199,7 @@ void ScreenSetupPage::build(Window* window)
|
|||||||
// Remove this screen from the model
|
// Remove this screen from the model
|
||||||
g_model.removeScreenLayout(customScreenIndex);
|
g_model.removeScreenLayout(customScreenIndex);
|
||||||
|
|
||||||
// Delete all custom screens
|
// Delete and reload custom screens
|
||||||
LayoutFactory::deleteCustomScreens();
|
|
||||||
|
|
||||||
// ... and reload
|
|
||||||
LayoutFactory::loadCustomScreens();
|
LayoutFactory::loadCustomScreens();
|
||||||
|
|
||||||
// adjust index if last screen deleted
|
// adjust index if last screen deleted
|
||||||
|
|||||||
@@ -642,6 +642,8 @@ void ModelLabelsWindow::newModel()
|
|||||||
luaExecStandalone(path);
|
luaExecStandalone(path);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
} else {
|
||||||
|
LayoutFactory::loadDefaultLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main view layout
|
// Main view layout
|
||||||
|
|||||||
@@ -127,10 +127,8 @@ HWPots::HWPots(Window* parent) :
|
|||||||
potsChanged = false;
|
potsChanged = false;
|
||||||
|
|
||||||
setCloseHandler([=]() {
|
setCloseHandler([=]() {
|
||||||
if (potsChanged) {
|
if (potsChanged)
|
||||||
LayoutFactory::deleteCustomScreens();
|
|
||||||
LayoutFactory::loadCustomScreens();
|
LayoutFactory::loadCustomScreens();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
new StaticText(this, {P_NM_X, -PAD_TINY, 0, 0}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
new StaticText(this, {P_NM_X, -PAD_TINY, 0, 0}, STR_NAME, COLOR_THEME_PRIMARY1_INDEX, FONT(XS));
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ void applyDefaultTemplate()
|
|||||||
g_model.resetScreenData();
|
g_model.resetScreenData();
|
||||||
LayoutFactory::deleteCustomScreens();
|
LayoutFactory::deleteCustomScreens();
|
||||||
LayoutFactory::deleteTopBarWidgets();
|
LayoutFactory::deleteTopBarWidgets();
|
||||||
LayoutFactory::loadDefaultLayout();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// enable switch warnings
|
// enable switch warnings
|
||||||
|
|||||||
@@ -44,7 +44,22 @@ void getModelPath(char * path, const char * filename, const char* pathName)
|
|||||||
strcpy(&path[len + 1], filename);
|
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");
|
TRACE("storageEraseAll");
|
||||||
|
|
||||||
@@ -60,24 +75,11 @@ void storageEraseAll(bool warn)
|
|||||||
g_eeGeneral.blOffBright = 20;
|
g_eeGeneral.blOffBright = 20;
|
||||||
#endif
|
#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);
|
RAISE_ALERT(STR_STORAGE_WARNING, STR_STORAGE_FORMAT, STR_PRESS_ANY_KEY_TO_SKIP, AU_NONE);
|
||||||
|
|
||||||
storageFormat();
|
storageFormat();
|
||||||
storageDirty(EE_GENERAL);
|
forceSave();
|
||||||
storageDirty(EE_MODEL);
|
|
||||||
storageCheck(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void storageFormat()
|
|
||||||
{
|
|
||||||
sdCheckAndCreateDirectory(RADIO_PATH);
|
|
||||||
sdCheckAndCreateDirectory(MODELS_PATH);
|
|
||||||
generalDefault();
|
|
||||||
setModelDefaults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void storageCheck(bool immediately)
|
void storageCheck(bool immediately)
|
||||||
@@ -166,10 +168,7 @@ const char * createModel()
|
|||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
setModelDefaults(index);
|
setModelDefaults(index);
|
||||||
memcpy(g_eeGeneral.currModelFilename, filename, sizeof(g_eeGeneral.currModelFilename));
|
memcpy(g_eeGeneral.currModelFilename, filename, sizeof(g_eeGeneral.currModelFilename));
|
||||||
|
forceSave();
|
||||||
storageDirty(EE_GENERAL);
|
|
||||||
storageDirty(EE_MODEL);
|
|
||||||
storageCheck(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postModelLoad(false);
|
postModelLoad(false);
|
||||||
@@ -222,12 +221,10 @@ void storageReadAll()
|
|||||||
simuCreateDefaultSettings = false;
|
simuCreateDefaultSettings = false;
|
||||||
storageFormat();
|
storageFormat();
|
||||||
g_eeGeneral.chkSum = evalChkSum();
|
g_eeGeneral.chkSum = evalChkSum();
|
||||||
storageDirty(EE_GENERAL);
|
forceSave();
|
||||||
storageDirty(EE_MODEL);
|
|
||||||
storageCheck(true);
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
storageEraseAll(true);
|
storageEraseAll();
|
||||||
}
|
}
|
||||||
#if !defined(STORAGE_MODELSLIST)
|
#if !defined(STORAGE_MODELSLIST)
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ extern tmr10ms_t rambackupDirtyTime10ms;
|
|||||||
//
|
//
|
||||||
// Generic storage interface
|
// Generic storage interface
|
||||||
//
|
//
|
||||||
void storageEraseAll(bool warn);
|
|
||||||
void storageFormat();
|
|
||||||
void storageReadAll();
|
void storageReadAll();
|
||||||
void storageCheck(bool immediately);
|
void storageCheck(bool immediately);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user