Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Aplication terminated when 2 script active at the same time.: (3 Items)
   
Aplication terminated when 2 script active at the same time.  
Hi everyone.

as you can see in the video that I attached in this email, there are 2 buttons to activate 2 scripts. the "OK" button 
used for activate timer.c, the timer.c is for create widget and move it horizontal and the other is for activate btn_psr
.c, btn_psr.c is for create widget and move it vertical

When I press the button one by one ( click the button, restart the application, and click the other button) it's work 
fine.

But when I click both button in the same time (without restart the application),the vertical widget is work fine, but 
after the sixth time horizontal widget is created the application is terminate.

do you know the reason why? is there something in my source code that make it happen?

thank you
best regards
Attachment: Text timer.c 2.9 KB Text btn_psr.c 1.94 KB Text 2 code work at same time_web480p_clipchamp.com.mp4 338.1 KB
Re: Aplication terminated when 2 script active at the same time.  
Afif,

unfortunately, the code and information you posted doesn't tell the whole story. One thing sticking out, though, is that
 you seem to use two arrays of widget pointers (my_label[] and my_label2[]) and two indices into these arrays (a and b) 
which keep being incremented on every timer tick. I don't know the exact sizes of the arrays, but letting the indices 
increase without bounds seems like a bad idea no matter how large the arrays are - sooner or later, you'll always be 
using "entries" beyond the array boundaries and will experience all kinds of effects. 

Also, since PtUnrealizeWidget() doesn't actually delete the widget object, you currently keep piling up unrealized 
widgets in the background. That's not what makes the application crash, but it causes a memory leak and will deteriorate
 the GUI's performance over time. 

Personally, I'd suggest using two arrays of six entries each. Create (and if possible, also realize) the widgets only 
once at startup time. Then, at each timer tick, re-calculate every widget's position and use PtSetResource() to set the 
Pt_ARG_POS resource of the widgets. That way, you can just move the existing widgets around instead of creating new ones
 every time.

Regards,
Thomas
Re: Aplication terminated when 2 script active at the same time.  
Hi  Mr. Thomas.

the arrays (my_label[ ] and my_label2[ ]) size is 5, it's already in global variable so it doesn't need to initalize. 
the a and b variable is for keep the tail of the widget is 5. 

I want to make it as Air trafic control, the widget is a plane..

can you explain to me more? I don't understand your advice.

thank you.
best regards
afif.