From 36e62b1047df85364f369ebee88be7ec3bbc519d Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Fri, 28 Mar 2014 14:08:48 +0100
Subject: [PATCH] Eeschema: fix Bug #1298868 (Can't create new schematic from
 main toolbar icon)

---
 eeschema/files-io.cpp | 18 +++++++++++-------
 eeschema/schframe.cpp |  6 +++---
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp
index f7c91d6570..54897bd5e5 100644
--- a/eeschema/files-io.cpp
+++ b/eeschema/files-io.cpp
@@ -368,20 +368,24 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
     // Delete old caches.
     CMP_LIBRARY::RemoveCacheLibrary();
 
-    libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() );
-
-    if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) && !libCacheExist )
+    if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) )
     {
         Zoom_Automatique( false );
-        msg.Printf( _( "File '%s' not found." ),
-                    GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
-        DisplayInfoMessage( this, msg );
-//        return false;
+
+        if( aCtl == 0 )
+        {
+            msg.Printf( _( "File '%s' not found." ),
+                        GetChars( g_RootSheet->GetScreen()->GetFileName() ) );
+            DisplayInfoMessage( this, msg );
+        return false;
+        }
+
         return true;    // do not close Eeschema if the file if not found:
                         // we may have to create a new schematic file.
     }
 
     // load the project.
+    libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() );
     g_RootSheet->SetScreen( NULL );
     bool diag = g_RootSheet->Load( this );
     SetScreen( m_CurrentSheet->LastScreen() );
diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp
index 1a1995f5a5..fa7cb5c5df 100644
--- a/eeschema/schframe.cpp
+++ b/eeschema/schframe.cpp
@@ -730,13 +730,13 @@ void SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile( wxCommandEvent& event )
 
 void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
 {
-    wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(),
+    wxFileDialog dlg( this, _( "New Schematic" ), wxGetCwd(),
                       wxEmptyString, SchematicFileWildcard,
-                      wxFD_OPEN | wxFD_FILE_MUST_EXIST );
+                      wxFD_SAVE );
 
     if( dlg.ShowModal() != wxID_CANCEL )
     {
-        OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
+        OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ), 1 );
     }
 }