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