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 ) 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 ); try
kiface->CreateWindow( m_frame, DIALOG_CONFIGUREPATHS, &m_frame->Kiway() ); {
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. DIALOG_CONFIGURE_PATHS dlg( m_frame, nullptr );
// A error message is displayed after trying to load _pcbnew.kiface.
if( dlg.ShowModal() == wxID_OK )
m_frame->Kiway().CommonSettingsChanged( true );
} }
return 0; return 0;
} }

View File

@ -114,6 +114,11 @@ static struct IFACE : public KIFACE_I
{ {
DIALOG_CONFIGURE_PATHS dlg( aParent, aKiway->Prj().Get3DFilenameResolver() ); 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 ) if( dlg.ShowModal() == wxID_OK )
aKiway->CommonSettingsChanged( true ); aKiway->CommonSettingsChanged( true );