How to debug OnDeinit() when chart was closed?

 

Hi,

as I see, there is no chance to debug the OnDeinit() when the chart is getting closed by the user by clicking the "X" at the right upper corner of the chart window. The debugger does simply never execute the function, while the live-code is executing it, of course. 

I face the issue, that I have completely different behavior of an EA between execution of OnDeinit() after ExpertRemove() and after manual chart closing. OnDeinit() has no issues when ExpertRemove() was called, but when the chart was closed manually, destroying process for <>1.000 objects takes <>4 seconds. Of course it must be a matter of my code, but how can I figure out the origin when I am not able to debug it? Is there a way to at least pretend this way of termination?

Thx.

 
Doerk Hilger:

Hi,

as I see, there is no chance to debug the OnDeinit() when the chart is getting closed by the user by clicking the "X" at the right upper corner of the chart window. The debugger does simply never execute the function, while the live-code is executing it, of course. 

I face the issue, that I have completely different behavior of an EA between execution of OnDeinit() after ExpertRemove() and after manual chart closing. OnDeinit() has no issues when ExpertRemove() was called, but when the chart was closed manually, destroying process for <>1.000 objects takes <>4 seconds. Of course it must be a matter of my code, but how can I figure out the origin when I am not able to debug it? Is there a way to at least pretend this way of termination?

Thx.

Are you talking about chart objects or OOP objects ?
 
Alain Verleyen:
Are you talking about chart objects or OOP objects ?

More than 1.000 chart objects

 
Doerk Hilger:

More than 1.000 chart objects

I already got an issue with ObjectsDeleteAll() with a chart closed. Detect it and don't delete the objects, not needed as the chart is closed anyway. I hope it helps.
 
Doerk Hilger:

Hi,

as I see, there is no chance to debug the OnDeinit() when the chart is getting closed by the user by clicking the "X" at the right upper corner of the chart window. The debugger does simply never execute the function, while the live-code is executing it, of course. 

I face the issue, that I have completely different behavior of an EA between execution of OnDeinit() after ExpertRemove() and after manual chart closing. OnDeinit() has no issues when ExpertRemove() was called, but when the chart was closed manually, destroying process for <>1.000 objects takes <>4 seconds. Of course it must be a matter of my code, but how can I figure out the origin when I am not able to debug it? Is there a way to at least pretend this way of termination?

Thx.

That does not need to be an issue of your code

OnDeinit() is placed into a queue (the same as class destructors) and is executed "when the terminal has some spare time" sort of speaking - hence that 4 seconds "pause" is not necessarily a result of your code issue. Use Print, and you shall see it in log file when it executes with that delay

Some more information here : https://www.mql5.com/en/forum/160715/page2

OnDeinit() race condition and recalculation issues
OnDeinit() race condition and recalculation issues
  • 2016.11.10
  • www.mql5.com
Hello, I am writing an indicator which draws certain objects in the chart...
 
Alain Verleyen:
I already got an issue with ObjectsDeleteAll() with a chart closed. Detect it and don't delete the objects, not needed as the chart is closed anyway. I hope it helps.

Will give it a try ... thx

Mladen Rakic:

That does not need to be an issue of your code

OnDeinit() is placed into a queue (the same as class destructors) and is executed "when the terminal has some spare time" sort of speaking - hence that 4 seconds "pause" is not necessarily a result of your code issue. Use Print, and you shall see it in log file when it executes with that delay

Some more information here : https://www.mql5.com/en/forum/160715/page2

It does not execute. Never. There is already a Print()-command which just says "Bye". Never seen it. 

 
Doerk Hilger: Will give it a try ... thx - It does not execute. Never. There is already a Print()-command which just says "Bye". Never seen it. 
I wonder if Print() actually works in OnDenit(). I vaguely remember once trying to print out something in the OnDenit() and I never got it to work.