Fixed memory leak with model select bitmap

This commit is contained in:
Raphael Coeffic
2021-06-14 17:22:17 +02:00
parent 058a44c9a7
commit dea8b3717b
+10 -1
View File
@@ -89,6 +89,11 @@ class ModelButton : public Button
load();
}
~ModelButton()
{
if (buffer) { delete buffer; }
}
void load()
{
uint8_t version;
@@ -115,6 +120,7 @@ class ModelButton : public Button
}
}
delete buffer;
buffer = new BitmapBuffer(BMP_RGB565, width(), height());
if (buffer == nullptr) {
return;
@@ -140,7 +146,10 @@ class ModelButton : public Button
void paint(BitmapBuffer *dc) override
{
FormField::paint(dc);
dc->drawBitmap(0, 0, buffer);
if (buffer)
dc->drawBitmap(0, 0, buffer);
if (modelCell == modelslist.getCurrentModel()) {
dc->drawSolidFilledRect(0, 0, width(), 20, HIGHLIGHT_COLOR);
dc->drawSizedText(width() / 2, 2, modelCell->modelName,