Projectkk2glider/issue 4099 leaks (#4617)

* Re #4099: memory leaks on model select screen fixed [Horus]

* Re #4099: memory leak in wizard background image [Horus]
This commit is contained in:
Damjan Adamic
2017-03-14 20:09:53 +01:00
committed by Bertrand Songis
parent 0020941740
commit b965cac481
2 changed files with 19 additions and 1 deletions
+4 -1
View File
@@ -125,6 +125,7 @@ uint8_t getWizardCount()
} }
} }
} }
f_closedir(&dir);
return wizCnt; return wizCnt;
} }
@@ -192,7 +193,8 @@ bool menuModelWizard(event_t event)
strcpy(&wizpath[sizeof(WIZARD_PATH)], fno.fname); strcpy(&wizpath[sizeof(WIZARD_PATH)], fno.fname);
strcpy(&wizpath[sizeof(WIZARD_PATH) + strlen(fno.fname)], "/icon.png"); strcpy(&wizpath[sizeof(WIZARD_PATH) + strlen(fno.fname)], "/icon.png");
lcdDrawText(x + 10, WIZARD_TEXT_Y, fno.fname); lcdDrawText(x + 10, WIZARD_TEXT_Y, fno.fname);
lcd->drawBitmap(x, WIZARD_ICON_Y, BitmapBuffer::load(wizpath)); BitmapBuffer * background = BitmapBuffer::load(wizpath);
lcd->drawBitmap(x, WIZARD_ICON_Y, background);
if(wizidx == wizardSelected ) { if(wizidx == wizardSelected ) {
if (wizardSelected < 5) { if (wizardSelected < 5) {
lcdDrawRect(x, WIZARD_ICON_Y, 85, 130, 2, SOLID, MAINVIEW_GRAPHICS_COLOR_INDEX); lcdDrawRect(x, WIZARD_ICON_Y, 85, 130, 2, SOLID, MAINVIEW_GRAPHICS_COLOR_INDEX);
@@ -207,6 +209,7 @@ bool menuModelWizard(event_t event)
} }
} }
} }
delete background;
} }
} }
} }
+15
View File
@@ -36,6 +36,13 @@ class ModelCell
strncpy(this->modelFilename, name, sizeof(this->modelFilename)); strncpy(this->modelFilename, name, sizeof(this->modelFilename));
} }
~ModelCell()
{
if (buffer) {
delete buffer;
}
}
const BitmapBuffer * getBuffer() const BitmapBuffer * getBuffer()
{ {
if (!buffer) { if (!buffer) {
@@ -100,6 +107,14 @@ class ModelsCategory: public std::list<ModelCell *>
strncpy(this->name, name, sizeof(this->name)); strncpy(this->name, name, sizeof(this->name));
} }
~ModelsCategory()
{
for (std::list<ModelCell *>::iterator it = begin(); it != end(); ++it) {
delete *it;
}
}
ModelCell * addModel(const char * name) ModelCell * addModel(const char * name)
{ {
ModelCell * result = new ModelCell(name); ModelCell * result = new ModelCell(name);