SciterEventHandler destructor
Closed this issue · 4 comments
I have issues with the destructor of this class SciterEventHandler. For my understanding, the code below is asserting that SciterSharp is keeping a copy of all attached instances to guard from GC removal?
In my case when the destructor is called _attached_handlers has the instances but the assert is triggered. In that case, should I detach the instances before closing the app? I did it and it is triggering the assertion anyways.
#if DEBUG
private volatile bool _is_attached = false;
~SciterEventHandler() { Debug.Assert(!_attached_handlers.Contains(this)); Debug.Assert(_is_attached == false); }
#endif
Thanks in advance
You don't need to dettach SciterEventHandler()
manuallly. Normally it should occur naturally when Sciter engine destroys the DOM element and ends calling: https://github.com/ramon-mendes/SciterSharp/blob/master/SciterSharp/SciterEventHandler.cs#L158
If it is not occurring, you are probably not destroying the Sciter window before app ends.
So, if that Debug.Assert() is triggering, something wrong is occurring in your app because the attached SciterEventHandler must, at sometime, be dettached when the corresponding DOM element is destroyed (which must occur in the app lifetime).
Close() generates WM_CLOSE message. See: https://docs.microsoft.com/en-us/windows/desktop/winmsg/wm-close
By default, the DefWindowProc function calls the DestroyWindow function to destroy the window.
Destroy() does destroys the window.
You can just start you C# app with http://misoftware.com.br/Bootstrap/Download
By default, when user clicks the close button, Window generates WM_CLOSE which ends up destroying the window
Let me know if you have more doubts..