Fixed memory leak with model select bitmap
This commit is contained in:
@@ -89,6 +89,11 @@ class ModelButton : public Button
|
|||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~ModelButton()
|
||||||
|
{
|
||||||
|
if (buffer) { delete buffer; }
|
||||||
|
}
|
||||||
|
|
||||||
void load()
|
void load()
|
||||||
{
|
{
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
@@ -115,6 +120,7 @@ class ModelButton : public Button
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete buffer;
|
||||||
buffer = new BitmapBuffer(BMP_RGB565, width(), height());
|
buffer = new BitmapBuffer(BMP_RGB565, width(), height());
|
||||||
if (buffer == nullptr) {
|
if (buffer == nullptr) {
|
||||||
return;
|
return;
|
||||||
@@ -140,7 +146,10 @@ class ModelButton : public Button
|
|||||||
void paint(BitmapBuffer *dc) override
|
void paint(BitmapBuffer *dc) override
|
||||||
{
|
{
|
||||||
FormField::paint(dc);
|
FormField::paint(dc);
|
||||||
dc->drawBitmap(0, 0, buffer);
|
|
||||||
|
if (buffer)
|
||||||
|
dc->drawBitmap(0, 0, buffer);
|
||||||
|
|
||||||
if (modelCell == modelslist.getCurrentModel()) {
|
if (modelCell == modelslist.getCurrentModel()) {
|
||||||
dc->drawSolidFilledRect(0, 0, width(), 20, HIGHLIGHT_COLOR);
|
dc->drawSolidFilledRect(0, 0, width(), 20, HIGHLIGHT_COLOR);
|
||||||
dc->drawSizedText(width() / 2, 2, modelCell->modelName,
|
dc->drawSizedText(width() / 2, 2, modelCell->modelName,
|
||||||
|
|||||||
Reference in New Issue
Block a user