Fix crash in wxSocketBase when the event handler has been destroyed.
Fixes KICAD-37B
Fixes https://gitlab.com/kicad/code/kicad/-/issues/18234
(cherry picked from commit ebdfeb4c0a
)
Co-authored-by: Alex Shvartzkop <dudesuchamazing@gmail.com>
This commit is contained in:
parent
02502342a5
commit
c5056beeb3
|
@ -57,7 +57,6 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType
|
||||||
|
|
||||||
KIWAY_PLAYER::~KIWAY_PLAYER() throw()
|
KIWAY_PLAYER::~KIWAY_PLAYER() throw()
|
||||||
{
|
{
|
||||||
|
|
||||||
// socket server must be destructed before we complete
|
// socket server must be destructed before we complete
|
||||||
// destructing the frame or else we could crash
|
// destructing the frame or else we could crash
|
||||||
// as the socket server holds a reference to this frame
|
// as the socket server holds a reference to this frame
|
||||||
|
@ -69,6 +68,20 @@ KIWAY_PLAYER::~KIWAY_PLAYER() throw()
|
||||||
delete m_socketServer;
|
delete m_socketServer;
|
||||||
m_socketServer = nullptr;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue