Fixup kiway by hand when dynamic_cast fails.

Also allows a shortened version of Configure Paths without the 3D
paths when Pcbnew isn't already running.

Fixes https://gitlab.com/kicad/code/kicad/issues/4568
This commit is contained in:
Jeff Young 2020-05-29 21:52:20 +01:00
parent 6d5b6c8b81
commit 112316cdfb
2 changed files with 26 additions and 6 deletions

View File

@ -77,16 +77,31 @@ void COMMON_CONTROL::Reset( RESET_REASON aReason )
int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent )
{
try // _pcbnew.kiface must be available: it contains the configure path dialog.
// If _pcbnew.kiface is running have it put up the dialog so the 3D paths can also
// be edited
KIFACE* pcbnew = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB, false );
if( pcbnew )
{
KIFACE* kiface = m_frame->Kiway().KiFACE( KIWAY::FACE_PCB );
kiface->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() );
try
{
pcbnew->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() );
}
catch( ... )
{
// Do nothing here.
// A error message is displayed after trying to load _pcbnew.kiface.
}
}
catch( ... )
else
{
// Do nothing here.
// A error message is displayed after trying to load _pcbnew.kiface.
DIALOG_CONFIGURE_PATHS dlg( m_frame, nullptr );
if( dlg.ShowModal() == wxID_OK )
m_frame->Kiway().CommonSettingsChanged( true );
}
return 0;
}

View File

@ -114,6 +114,11 @@ static struct IFACE : public KIFACE_I
{
DIALOG_CONFIGURE_PATHS dlg( aParent, aKiway->Prj().Get3DFilenameResolver() );
// The dialog's constructor probably failed to set its Kiway because the
// dynamic_cast fails when aParent was allocated by a separate compiliation
// module. So set it directly.
dlg.SetKiway( &dlg, aKiway );
if( dlg.ShowModal() == wxID_OK )
aKiway->CommonSettingsChanged( true );