diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index bc69f98340..7adeca893c 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -174,6 +174,8 @@ void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event ) } break; } + + UpdateTitle(); } @@ -477,6 +479,8 @@ void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent ) SaveEEFile( screen ); CreateArchiveLibraryCacheFile(); + + UpdateTitle(); } diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index fca168e051..896b4736f6 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -46,10 +46,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile() { - wxFileName fn; - SCH_SCREENS ScreenList; - - fn = ScreenList.GetFirst()->GetFileName(); + wxFileName fn = GetScreen()->GetFileName(); fn.SetName( fn.GetName() + wxT( "-cache" ) ); fn.SetExt( SchematicLibraryFileExtension ); diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 9f5d28d5ea..3bba1609b5 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -514,8 +514,7 @@ double SCH_EDIT_FRAME::BestZoom() wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet() { - SCH_SCREENS ScreenList; - wxFileName fn = ScreenList.GetFirst()->GetFileName(); + wxFileName fn = GetScreen()->GetFileName(); #ifndef KICAD_GOST wxString filename = fn.GetName(); diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index 9d8f08cddb..829ff0b1d7 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -177,10 +178,25 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) if( newProject ) { - if ( !m_ProjectFileName.GetFullPath().EndsWith( g_KicadPrjFilenameExtension ) ) + m_ProjectFileName.SetExt( ProjectFileExtension ); + + // Check if the project directory is empty + wxDir directory ( m_ProjectFileName.GetPath() ); + if( directory.HasFiles() ) { - m_ProjectFileName.SetFullName( m_ProjectFileName.GetFullPath() + - g_KicadPrjFilenameExtension ); + wxString msg = _( "The selected directory is not empty. " + "We recommend you create projects in their own clean directory.\n\n" + "Do you want to create a new empty directory for the project?" ); + + if( IsOK( this, msg ) ) + { + // Append a new directory with the same name of the project file + // and try to create it + m_ProjectFileName.AppendDir( m_ProjectFileName.GetName() ); + if( !wxMkdir( m_ProjectFileName.GetPath() ) ) + // There was a problem, undo + m_ProjectFileName.RemoveLastDir(); + } } if( event.GetId() == ID_NEW_PROJECT )