diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index 366bc1687d..1dd4338afc 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -199,6 +199,7 @@ set( EESCHEMA_SRCS
pin_numbers.cpp
pin_type.cpp
project_rescue.cpp
+ project_sch_specific.cpp
sch_base_frame.cpp
sch_bitmap.cpp
sch_bus_entry.cpp
diff --git a/eeschema/project_sch_specific.cpp b/eeschema/project_sch_specific.cpp
new file mode 100644
index 0000000000..7b1e494f24
--- /dev/null
+++ b/eeschema/project_sch_specific.cpp
@@ -0,0 +1,126 @@
+/*
+ * This program source code file is part of KiCad, a free EDA CAD application.
+ *
+ * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see .
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+// non-member so it can be moved easily, and kept REALLY private.
+// Do NOT Clear() in here.
+static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
+{
+ for( unsigned i=0; iAddPaths( aSrc[i], aIndex );
+}
+
+
+SEARCH_STACK* PROJECT::SchSearchS()
+{
+ SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK );
+
+ wxASSERT( !ss || dynamic_cast( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
+
+ if( !ss )
+ {
+ ss = new SEARCH_STACK();
+
+ // Make PROJECT the new SEARCH_STACK owner.
+ SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss );
+
+ // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
+ ss->AddPaths( m_project_name.GetPath() );
+
+ // next add the paths found in *.pro, variable "LibDir"
+ wxString libDir;
+
+ try
+ {
+ SYMBOL_LIBS::LibNamesAndPaths( this, false, &libDir );
+ }
+ catch( const IO_ERROR& )
+ {
+ }
+
+ if( !!libDir )
+ {
+ wxArrayString paths;
+
+ SEARCH_STACK::Split( &paths, libDir );
+
+ for( unsigned i =0; iAddPaths( path ); // at the end
+ }
+ }
+
+ // append all paths from aSList
+ add_search_paths( ss, Kiface().KifaceSearch(), -1 );
+ }
+
+ return ss;
+}
+
+
+SYMBOL_LIBS* PROJECT::SchLibs()
+{
+ SYMBOL_LIBS* libs = (SYMBOL_LIBS*) GetElem( PROJECT::ELEM_SCH_SYMBOL_LIBS );
+
+ wxASSERT( !libs || libs->Type() == SYMBOL_LIBS_T );
+
+ if( !libs )
+ {
+ libs = new SYMBOL_LIBS();
+
+ // Make PROJECT the new SYMBOL_LIBS owner.
+ SetElem( PROJECT::ELEM_SCH_SYMBOL_LIBS, libs );
+
+ try
+ {
+ libs->LoadAllLibraries( this );
+ }
+ catch( const PARSE_ERROR& pe )
+ {
+ wxString lib_list = UTF8( pe.inputLine );
+ wxWindow* parent = Pgm().App().GetTopWindow();
+
+ // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
+ HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
+
+ dlg.MessageSet( _( "The following libraries were not found:" ) );
+ dlg.ListSet( lib_list );
+ dlg.Layout();
+
+ dlg.ShowModal();
+ }
+ catch( const IO_ERROR& ioe )
+ {
+ wxWindow* parent = Pgm().App().GetTopWindow();
+
+ DisplayError( parent, ioe.What() );
+ }
+ }
+
+ return libs;
+}
diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp
index cebef0e2ee..b0cbe08036 100644
--- a/eeschema/sch_edit_frame.cpp
+++ b/eeschema/sch_edit_frame.cpp
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
- * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -89,108 +89,6 @@
#include
#include
-// non-member so it can be moved easily, and kept REALLY private.
-// Do NOT Clear() in here.
-static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
-{
- for( unsigned i=0; iAddPaths( aSrc[i], aIndex );
-}
-
-
-SEARCH_STACK* PROJECT::SchSearchS()
-{
- SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK );
-
- wxASSERT( !ss || dynamic_cast( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
-
- if( !ss )
- {
- ss = new SEARCH_STACK();
-
- // Make PROJECT the new SEARCH_STACK owner.
- SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss );
-
- // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
- ss->AddPaths( m_project_name.GetPath() );
-
- // next add the paths found in *.pro, variable "LibDir"
- wxString libDir;
-
- try
- {
- SYMBOL_LIBS::LibNamesAndPaths( this, false, &libDir );
- }
- catch( const IO_ERROR& )
- {
- }
-
- if( !!libDir )
- {
- wxArrayString paths;
-
- SEARCH_STACK::Split( &paths, libDir );
-
- for( unsigned i =0; iAddPaths( path ); // at the end
- }
- }
-
- // append all paths from aSList
- add_search_paths( ss, Kiface().KifaceSearch(), -1 );
- }
-
- return ss;
-}
-
-
-SYMBOL_LIBS* PROJECT::SchLibs()
-{
- SYMBOL_LIBS* libs = (SYMBOL_LIBS*) GetElem( PROJECT::ELEM_SCH_SYMBOL_LIBS );
-
- wxASSERT( !libs || libs->Type() == SYMBOL_LIBS_T );
-
- if( !libs )
- {
- libs = new SYMBOL_LIBS();
-
- // Make PROJECT the new SYMBOL_LIBS owner.
- SetElem( PROJECT::ELEM_SCH_SYMBOL_LIBS, libs );
-
- try
- {
- libs->LoadAllLibraries( this );
- }
- catch( const PARSE_ERROR& pe )
- {
- wxString lib_list = UTF8( pe.inputLine );
- wxWindow* parent = Pgm().App().GetTopWindow();
-
- // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
- HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
-
- dlg.MessageSet( _( "The following libraries were not found:" ) );
-
- dlg.ListSet( lib_list );
-
- dlg.Layout();
-
- dlg.ShowModal();
- }
- catch( const IO_ERROR& ioe )
- {
- wxWindow* parent = Pgm().App().GetTopWindow();
-
- DisplayError( parent, ioe.What() );
- }
- }
-
- return libs;
-}
-
BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
@@ -885,6 +783,9 @@ void SCH_EDIT_FRAME::doCloseWindow()
if( !Schematic().GetFileName().IsEmpty() && !Schematic().RootScreen()->IsEmpty() )
UpdateFileHistory( fileName );
+ // Make sure local settings are persisted
+ SaveProjectSettings();
+
Schematic().RootScreen()->Clear();
// all sub sheets are deleted, only the main sheet is usable