Clear the playerFrame lookup cache when closing frames.

WindowIds aren't actually guaranteed to be unique, and we don't
perform a dynamic_cast on the result of FindWindowById() because
of linker issues....

This is an attempt to fix KICAD-39.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14928
This commit is contained in:
Jeff Young 2023-06-11 20:30:52 +01:00
parent eaf65f7d53
commit d6aefc458c
3 changed files with 14 additions and 8 deletions

View File

@ -506,7 +506,7 @@ bool KIWAY::PlayerClose( FRAME_T aFrameType, bool doForce )
return false;
}
KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
KIWAY_PLAYER* frame = GetPlayerFrame( aFrameType );
if( frame == nullptr ) // Already closed
return true;
@ -538,14 +538,18 @@ bool KIWAY::PlayersClose( bool doForce )
bool ret = true;
for( unsigned i=0; i < KIWAY_PLAYER_COUNT; ++i )
{
ret = ret && PlayerClose( FRAME_T( i ), doForce );
}
return ret;
}
void KIWAY::PlayerDidClose( FRAME_T aFrameType )
{
m_playerFrameId[aFrameType] = wxID_NONE;
}
void KIWAY::ExpressMail( FRAME_T aDestination, MAIL_T aCommand, std::string& aPayload,
wxWindow* aSource )
{

View File

@ -170,6 +170,8 @@ bool KIWAY_PLAYER::ShowModal( wxString* aResult, wxWindow* aResultantFocusWindow
bool KIWAY_PLAYER::Destroy()
{
Kiway().PlayerDidClose( GetFrameType() );
return EDA_BASE_FRAME::Destroy();
}

View File

@ -358,6 +358,11 @@ public:
*/
virtual bool PlayersClose( bool doForce );
/**
* Notifies a Kiway that a player has been closed.
*/
void PlayerDidClose( FRAME_T aFrameType );
/**
* Send @a aPayload to @a aDestination from @a aSource.
*
@ -434,11 +439,6 @@ private:
/// Get the [path &] name of the DSO holding the requested FACE_T.
const wxString dso_search_path( FACE_T aFaceId );
#if 0
/// hooked into m_top in SetTop(), marks child frame as closed.
void player_destroy_handler( wxWindowDestroyEvent& event );
#endif
bool set_kiface( FACE_T aFaceType, KIFACE* aKiface )
{
if( (unsigned) aFaceType < (unsigned) KIWAY_FACE_COUNT )