The delayed destruction mechanism is not MT-safe, so using it for wxSocket
objects destroyed from threads other than main resulted in crashes. Luckily,
it is not necessary to use it for such sockets anyhow as they don't risk
receiving any events -- which are only dispatched in the main thread -- and so
can be destroyed immediately.
So do destroy them directly instead of just scheduling for later destruction
when wxSocket::Destroy() is called.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72158
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
Notify(false);
// Schedule this object for deletion instead of destroying it right now if
- // possible as we may have other events pending for it
- if ( wxTheApp )
+ // it can have other events pending for it and we have a way to do it.
+ //
+ // Notice that sockets used in other threads won't have any events for them
+ // and we shouldn't use delayed destruction mechanism for them as it's not
+ // MT-safe.
+ if ( wxIsMainThread() && wxTheApp )
{
wxTheApp->ScheduleForDestruction(this);
}