2020-11-04 04:33 AM
So I tried creating a box in the buttoncallback function as follows :
touchgfx::Box * box_temp = new touchgfx::Box();
box_temp->setPosition(170,180,500,220);
box_temp->setColor(touchgfx::Color::getColorFrom24BitRGB(255,255,255));
box_temp->setVisible(true);
add(*box_temp);
box_temp->invalidate();
but on pressing the button the app freezes.
When tried to debug on trying to allocate memory using new the control reaches on
hardfault_handler(){}
Any suggestions?
Solved! Go to Solution.
2020-11-08 09:54 PM
Hello,
TouchGFX is allocating statically memory so you should avoid trying to create widgets dynamically.
One solution would be to create your box already in the Designer and then make it appear only at the right moment using setVisible(true). This way you ensure that the memory is correctly allocated for your Box and as long as the Box is not visible TouchGFX does not care about it (so it does not render it).
When your question is answered, please close this topic by choosing Select as Best.
/Alexandre
2020-11-08 09:54 PM
Hello,
TouchGFX is allocating statically memory so you should avoid trying to create widgets dynamically.
One solution would be to create your box already in the Designer and then make it appear only at the right moment using setVisible(true). This way you ensure that the memory is correctly allocated for your Box and as long as the Box is not visible TouchGFX does not care about it (so it does not render it).
When your question is answered, please close this topic by choosing Select as Best.
/Alexandre