[SOLVED] Terminal freezing after some time

 

Hi,


this is a post about a problem I managed to solve; the main goal here is to make the knowledge of the problem public available in case other people experience the same situation.

I developed a set of indicators and a EA and everything was running fine in the development terminal which I use with a demo account. But whenever I copied this set of tools to a second terminal with a real account, eventually it would freeze requiring restart.

I was lost trying to understand why no problem happened in one terminal and did in the second one. I tried to catch all the diferences between them to no use: different version (the buggy was in beta), some code related to demo vs real account, etc.. To make things worst, some times it would seem the bug was in one of the indicators and some times it appeared it was in the EA.

Finally I got the problem: one of the indicators was using an alert system which makes use of sound files loaded as resources, but I forgot to add the files as #resource in the source code. Then for whatever reason instead of the MQL5 compiler point me out "hey, in your code you're calling to play a resource with :: but no such resource was loaded with #resource", no warning was given. To make things worst, when I used the indicator in my developoment terminal, instead of complaining, PlaySound would just call for the local sound file instead of resource making it appear there was no problem. And finally, when the indicator was used in a separated terminal where no local copies of the sound files were available, instead of showing some message "hey, you're asking me to PlaySound this :: file, but no such resource is available; it won't play anything", nope, it would just freeze the entire Terminal "like a charm" giving me no hints to where was the problem.

So that was the problem and its cause. I just added the #resource and got no more freezes. It's unfortunately that MQL5 and the compiler didn't do a better job handling this situation and, in part, I wrote this forum hoping that someone in MetaQuotes will come to know this problem and fix the issue. Full terminal freeze with no message for forgetting to add the #resource is far from adequate.

 

PlaySound() returns a bool, were you checking it ?

So a simple code with PlaySound() using a resource, but no #resource directive would allow to reproduce the issue ? Or is it related to some more complex structure like indicators used inside an EA ?

If you want to help and have it fixed, a simple code to reproduce the issue is the best way.

 
Alain Verleyen:

PlaySound() returns a bool, were you checking it ?

So a simple code with PlaySound() using a resource, but no #resource directive would allow to reproduce the issue ? Or is it related to some more complex structure like indicators used inside an EA ?

If you want to help and have it fixed, a simple code to reproduce the issue is the best way.

Well, I don't remember if  was evaluating the return of PlaySound, but given that the Terminal was freezing, I guess it wouldn't return me anything.

Regarding reproduction, I guess yes! A simple code calling a resource after let's say a call from OnTimer would do the trick AFAIK.

Now I've return here actually to complement the problem above with a similar one: 

I was doing another indicator with another alert system and, once again, I was having Terminal freezes when dealing with PlaySound. But this time all the needed resources were included with the #resource directive.

So when I was debugging, I decided to open the project file (double click) and see the list of resources. There I found a 'trash': previsouly, I had added another wav file as resource and, upon not needing it anymore, I removed the #resource call from within the code but the project file still listed it as part of the project. So I clicked with the right button and moved to remove it from the project. After that, though, I still had Terminal freezes. So I proceeded to complete erase the project file in Explorer and commanded to create a new one (with that function 'create project file from existing project'). After recompiling with a fresh new project file, the bug disappeared.