cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic create widget by 'new' and 'delete', the project crash!

V.H
Senior

Hello all,

I dynamic create widget by 'new' and delete by 'delete', but the project crash when delete it.

Are there any examples of that used ?

I have 100 custom containers in a screen, but only one will be displayed at a time.

So I dynamic create one of these custom containers when used and delete when unused.

7 REPLIES 7
Yoann KLEIN
ST Employee

Hello @V.H​ ,

Could you please share your whole project ? Not only the UI files.

Thanks,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX

I upload my project, now. That's a little big so I just upload the UI file before.

This problem has been bothering me for a long time and has not been properly solved. Help me, please.

V.H
Senior

Any Ideas?​

Hello @V.H​ ,

I investigated but didn't find the issue, your code seems correct to me.

After discussing with colleagues, they only said that it is not recommended to dynamically create widgets, because TouchGFX is allocating statically memory.

So, we strongly recommend people to create their widgets manually in TouchGFXDesigner, set them at non-visible and then show them at runtime.

We know that some customers like you have a lot of widgets they want to create dynamically, so we encourage instead at factorizing and reducing the number of widget, and then dynamically change the data displayed inside.

Hope that you will find a solution,

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX

Hi @Yoann KLEIN​ 

1, It create a screen with a button at system start;

2, Click the button to new a "Modal Window" with a gray image;

3, Click area without the the gray image to return then delete;

0693W00000SvwbzQAB.png0693W00000Svwc9QAB.png0693W00000SvwcEQAR.png 

Hi @Yoann KLEIN​ ​

class Screen

{

......

  Drawable* focus; ///< The drawable currently in focus (set when DOWN_PRESSED is received).

......

};

This was the root of the crash problem I think.

"focus" need clear to NULL when the "Modal Window" was been deleted.

Do you agree?