mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
[Horus] Malloc check added
This commit is contained in:
parent
cdb3f48da7
commit
d60de4466a
7 changed files with 50 additions and 23 deletions
|
@ -507,6 +507,10 @@ void printTaskSwitchLog()
|
|||
serialPrint("Tasks switch log at %u [<time>, <task_id>]:", get_tmr10ms());
|
||||
uint32_t lastSwitchTime = 0;
|
||||
uint32_t * tsl = new uint32_t[DEBUG_TASKS_LOG_SIZE];
|
||||
if (!tsl) {
|
||||
serialPrint("Not enough memory");
|
||||
return 0;
|
||||
}
|
||||
memcpy(tsl, taskSwitchLog, sizeof(taskSwitchLog));
|
||||
uint32_t * p = tsl + taskSwitchLogPos;
|
||||
uint32_t * end = tsl + DEBUG_TASKS_LOG_SIZE;
|
||||
|
|
|
@ -504,8 +504,10 @@ BitmapBuffer * BitmapBuffer::loadMaskOnBackground(const char * filename, LcdFlag
|
|||
BitmapBuffer * mask = BitmapBuffer::loadMask(getThemePath(filename));
|
||||
if (mask) {
|
||||
result = new BitmapBuffer(BMP_RGB565, mask->getWidth(), mask->getHeight());
|
||||
if (result) {
|
||||
result->clear(background);
|
||||
result->drawMask(0, 0, mask, foreground);
|
||||
}
|
||||
delete mask;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -94,9 +94,10 @@ BitmapBuffer * createFontCache(const uint8_t * font, LcdFlags fg, LcdFlags bg)
|
|||
coord_t height = *(((uint16_t *)font)+1);
|
||||
|
||||
BitmapBuffer * buffer = new BitmapBuffer(BMP_RGB565, width, height);
|
||||
if (buffer) {
|
||||
buffer->clear(bg);
|
||||
buffer->drawBitmapPattern(0, 0, font, fg);
|
||||
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,14 +98,18 @@ class BaseLayoutFactory: public LayoutFactory
|
|||
virtual Layout * create(Layout::PersistentData * persistentData) const
|
||||
{
|
||||
Layout * layout = new T(this, persistentData);
|
||||
if (layout) {
|
||||
layout->create();
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
virtual Layout * load(Layout::PersistentData * persistentData) const
|
||||
{
|
||||
Layout * layout = new T(this, persistentData);
|
||||
if (layout) {
|
||||
layout->load();
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,13 +66,17 @@ class DarkblueTheme: public Theme
|
|||
BitmapBuffer * mask = BitmapBuffer::loadMask(getThemePath(filename));
|
||||
if (mask) {
|
||||
menuIconNormal[index] = new BitmapBuffer(BMP_RGB565, mask->getWidth(), mask->getHeight());
|
||||
if (menuIconNormal[index]) {
|
||||
menuIconNormal[index]->clear(HEADER_BGCOLOR);
|
||||
menuIconNormal[index]->drawMask(0, 0, mask, HEADER_CURRENT_BGCOLOR);
|
||||
}
|
||||
menuIconSelected[index] = new BitmapBuffer(BMP_RGB565, mask->getWidth(), mask->getHeight());
|
||||
if (menuIconSelected[index]) {
|
||||
menuIconSelected[index]->clear(HEADER_BGCOLOR);
|
||||
menuIconSelected[index]->drawMask(0, 0, mask, MENU_TITLE_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadMenusIcons() const
|
||||
{
|
||||
|
|
|
@ -74,12 +74,16 @@ class DefaultTheme: public Theme
|
|||
if (mask) {
|
||||
delete menuIconNormal[index];
|
||||
menuIconNormal[index] = new BitmapBuffer(BMP_RGB565, mask->getWidth(), mask->getHeight());
|
||||
if (menuIconNormal[index]) {
|
||||
menuIconNormal[index]->clear(HEADER_BGCOLOR);
|
||||
menuIconNormal[index]->drawMask(0, 0, mask, color);
|
||||
}
|
||||
delete menuIconSelected[index];
|
||||
menuIconSelected[index] = new BitmapBuffer(BMP_RGB565, mask->getWidth(), mask->getHeight());
|
||||
if (menuIconSelected[index]) {
|
||||
menuIconSelected[index]->clear(HEADER_CURRENT_BGCOLOR);
|
||||
menuIconSelected[index]->drawMask(0, 0, mask, color);
|
||||
}
|
||||
delete mask;
|
||||
}
|
||||
}
|
||||
|
@ -136,13 +140,17 @@ class DefaultTheme: public Theme
|
|||
BitmapBuffer * shadow = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_shadow.png"));
|
||||
BitmapBuffer * dot = BitmapBuffer::loadMask(getThemePath("mask_currentmenu_dot.png"));
|
||||
|
||||
if (!currentMenuBackground) currentMenuBackground = new BitmapBuffer(BMP_RGB565, 36, 53);
|
||||
if (!currentMenuBackground) {
|
||||
currentMenuBackground = new BitmapBuffer(BMP_RGB565, 36, 53);
|
||||
}
|
||||
if (currentMenuBackground) {
|
||||
currentMenuBackground->drawSolidFilledRect(0, 0, currentMenuBackground->getWidth(), MENU_HEADER_HEIGHT, HEADER_BGCOLOR);
|
||||
currentMenuBackground->drawSolidFilledRect(0, MENU_HEADER_HEIGHT, currentMenuBackground->getWidth(), MENU_TITLE_TOP - MENU_HEADER_HEIGHT, TEXT_BGCOLOR);
|
||||
currentMenuBackground->drawSolidFilledRect(0, MENU_TITLE_TOP, currentMenuBackground->getWidth(), currentMenuBackground->getHeight() - MENU_TITLE_TOP, TITLE_BGCOLOR);
|
||||
currentMenuBackground->drawMask(0, 0, background, HEADER_CURRENT_BGCOLOR);
|
||||
currentMenuBackground->drawMask(0, 0, shadow, TRIM_SHADOW_COLOR);
|
||||
currentMenuBackground->drawMask(10, 39, dot, MENU_TITLE_COLOR);
|
||||
}
|
||||
|
||||
delete topleftBitmap;
|
||||
topleftBitmap = BitmapBuffer::loadMaskOnBackground("topleft.png", TITLE_BGCOLOR, HEADER_BGCOLOR);
|
||||
|
|
|
@ -50,13 +50,17 @@ class ModelCell
|
|||
const char * error = NULL;
|
||||
|
||||
buffer = new BitmapBuffer(BMP_RGB565, MODELCELL_WIDTH, MODELCELL_HEIGHT);
|
||||
buffer->clear(TEXT_BGCOLOR);
|
||||
if (buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp(modelFilename, g_eeGeneral.currModelFilename, LEN_MODEL_FILENAME) == 0)
|
||||
header = g_model.header;
|
||||
else
|
||||
error = readModel(modelFilename, (uint8_t *)&header, sizeof(header));
|
||||
|
||||
buffer->clear(TEXT_BGCOLOR);
|
||||
|
||||
if (error) {
|
||||
buffer->drawText(5, 2, "(Invalid Model)", TEXT_COLOR);
|
||||
buffer->drawBitmapPattern(5, 23, LBM_LIBRARY_SLOT, TEXT_COLOR);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue