Fix KiCad crash when no template is selected on new project from template. (fixes lp:1170973)
This commit is contained in:
parent
74c64958f4
commit
d3f28fb71c
|
@ -56,7 +56,8 @@ static const wxString GeneralGroupName( wxT( "/general" ) );
|
||||||
PARAM_CFG_ARRAY s_KicadManagerParams;
|
PARAM_CFG_ARRAY s_KicadManagerParams;
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, bool aTemplateSelector = false )
|
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName,
|
||||||
|
bool aTemplateSelector = false )
|
||||||
{
|
{
|
||||||
wxString filename;
|
wxString filename;
|
||||||
wxFileName newProjectName = aPrjFullFileName;
|
wxFileName newProjectName = aPrjFullFileName;
|
||||||
|
@ -118,12 +119,16 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
|
||||||
// Show the project template selector dialog
|
// Show the project template selector dialog
|
||||||
int result = ps->ShowModal();
|
int result = ps->ShowModal();
|
||||||
|
|
||||||
if( result != wxID_OK )
|
if( (result != wxID_OK) || (ps->GetWidget() == NULL) )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Did not generate new project from template" ),
|
if( ps->GetWidget() == NULL )
|
||||||
_( "Cancelled new project from template" ),
|
{
|
||||||
wxOK | wxICON_EXCLAMATION,
|
wxMessageBox( _( "No project template was selected. Cannot generate new "
|
||||||
this );
|
"project." ),
|
||||||
|
_( "Error" ),
|
||||||
|
wxOK | wxICON_ERROR,
|
||||||
|
this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -132,7 +137,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
|
||||||
if( !ps->GetWidget()->GetTemplate()->CreateProject( newProjectName ) )
|
if( !ps->GetWidget()->GetTemplate()->CreateProject( newProjectName ) )
|
||||||
{
|
{
|
||||||
wxMessageBox( _( "Problem whilst creating new project from template!" ),
|
wxMessageBox( _( "Problem whilst creating new project from template!" ),
|
||||||
_( "Could not generate new project" ),
|
_( "Template Error" ),
|
||||||
wxOK | wxICON_ERROR,
|
wxOK | wxICON_ERROR,
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
|
@ -205,17 +210,19 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
|
|
||||||
// Check if the project directory is empty
|
// Check if the project directory is empty
|
||||||
wxDir directory ( m_ProjectFileName.GetPath() );
|
wxDir directory ( m_ProjectFileName.GetPath() );
|
||||||
|
|
||||||
if( directory.HasFiles() )
|
if( directory.HasFiles() )
|
||||||
{
|
{
|
||||||
wxString msg = _( "The selected directory is not empty. "
|
wxString msg = _( "The selected directory is not empty. We recommend you "
|
||||||
"We recommend you create projects in their own clean directory.\n\n"
|
"create projects in their own clean directory.\n\nDo you "
|
||||||
"Do you want to create a new empty directory for the project?" );
|
"want to create a new empty directory for the project?" );
|
||||||
|
|
||||||
if( IsOK( this, msg ) )
|
if( IsOK( this, msg ) )
|
||||||
{
|
{
|
||||||
// Append a new directory with the same name of the project file
|
// Append a new directory with the same name of the project file
|
||||||
// and try to create it
|
// and try to create it
|
||||||
m_ProjectFileName.AppendDir( m_ProjectFileName.GetName() );
|
m_ProjectFileName.AppendDir( m_ProjectFileName.GetName() );
|
||||||
|
|
||||||
if( !wxMkdir( m_ProjectFileName.GetPath() ) )
|
if( !wxMkdir( m_ProjectFileName.GetPath() ) )
|
||||||
// There was a problem, undo
|
// There was a problem, undo
|
||||||
m_ProjectFileName.RemoveLastDir();
|
m_ProjectFileName.RemoveLastDir();
|
||||||
|
|
Loading…
Reference in New Issue