Fix crash in wxSocketBase when the event handler has been destroyed.

Fixes KICAD-37B
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18234
This commit is contained in:
Alex Shvartzkop 2024-06-19 00:49:53 +03:00
parent e1ffd956e6
commit ebdfeb4c0a
1 changed files with 14 additions and 1 deletions

View File

@ -57,7 +57,6 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType
KIWAY_PLAYER::~KIWAY_PLAYER() throw()
{
// socket server must be destructed before we complete
// destructing the frame or else we could crash
// as the socket server holds a reference to this frame
@ -69,6 +68,20 @@ KIWAY_PLAYER::~KIWAY_PLAYER() throw()
delete m_socketServer;
m_socketServer = nullptr;
}
// remove active sockets as well
for( wxSocketBase* socket : m_sockets )
{
if( !socket )
continue;
// ensure any event handling stops
socket->Notify( false );
delete socket;
}
m_sockets.clear();
}