Commit c698a1da authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: fix unwanted creation of noname.pro (or other useless config file),...

Eeschema: fix unwanted creation of noname.pro (or other useless config file), when opening eeschema. Fix also an issue when saving the config (from save config menu) which saved the config file in an unknow folder.
parent 0ff0b9b8
......@@ -60,9 +60,9 @@ void PROJECT::SetProjectFullName( const wxString& aFullPathAndName )
wxASSERT( m_project_name.GetName() == NAMELESS_PROJECT || m_project_name.IsAbsolute() );
#if 0
wxASSERT( m_project_name.GetExt() == wxT( ".pro" ) )
wxASSERT( m_project_name.GetExt() == ProjectFileExtension )
#else
m_project_name.SetExt( wxT( ".pro" ) );
m_project_name.SetExt( ProjectFileExtension );
#endif
// until multiple projects are in play, set an environment variable for the
......@@ -269,19 +269,21 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
// No suitable pro file was found, either does not exist, or is too old.
// Use the template kicad.pro file. Find it by using caller's SEARCH_STACK.
wxString kicad_pro_template = aSList.FindValidPath( wxT( "kicad.pro" ) );
wxString templateFile = wxT( "kicad." ) + ProjectFileExtension;
wxString kicad_pro_template = aSList.FindValidPath( templateFile );
if( !kicad_pro_template )
{
wxLogDebug( wxT( "Template file <kicad.pro> not found using search paths." ) );
wxLogDebug( wxT( "Template file <%s> not found using search paths." ),
GetChars( templateFile ) );
wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
if( !templ.IsFileReadable() )
{
wxString msg = wxString::Format( _( "Unable to find kicad.pro template file." ) );
wxString msg = wxString::Format( _( "Unable to find %s template config file." ),
GetChars( templateFile ) );
DisplayError( NULL, msg );
......@@ -291,8 +293,12 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
kicad_pro_template = templ.GetFullPath();
}
// copy the template to cur_pro_fn, and open it at that destination.
wxCopyFile( kicad_pro_template, cur_pro_fn );
// The project config file is not found (happens for new projects,
// or if the schematic editor is run outside an existing project
// In this case the default template (kicad.pro) is used
cur_pro_fn = kicad_pro_template;
wxLogDebug( wxT( "Use template file '%s' as project file." ), GetChars( cur_pro_fn ) );
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
......
......@@ -40,7 +40,6 @@
#include <general.h>
#include <class_libentry.h>
//#include <sch_junction.h>
#include <hotkeys.h>
#include <dialogs/dialog_color_config.h>
#include <transform.h>
......
......@@ -139,7 +139,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
switch( id )
{
case ID_CONFIG_SAVE:
schFrame->SaveProjectSettings( false );
schFrame->SaveProjectSettings( true );
break;
case ID_CONFIG_READ:
......@@ -205,7 +205,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
switch( id )
{
case ID_CONFIG_SAVE:
SaveProjectSettings( false );
SaveProjectSettings( true );
break;
case ID_CONFIG_READ:
......@@ -456,8 +456,8 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
if( aAskForSave )
{
wxFileDialog dlg( this, _( "Save Project File" ),
fn.GetPath(), fn.GetFullName(),
ProjectFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR );
fn.GetPath(), fn.GetFullPath(),
ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL )
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment