Don't create new project files when opening boards/schematics
Display warning infobar in the board/schematic setup when no project is loaded, since most of the settings in those dialogs are saved in the project and not in the board/schematic file. Fixes https://gitlab.com/kicad/code/kicad/-/issues/4868
This commit is contained in:
parent
eda0f1a27f
commit
24435fcc62
|
@ -24,6 +24,7 @@
|
|||
#include <wx/grid.h>
|
||||
#include <wx/statline.h>
|
||||
|
||||
#include <widgets/infobar.h>
|
||||
#include <widgets/paged_dialog.h>
|
||||
#include <wx/stc/stc.h>
|
||||
|
||||
|
@ -91,6 +92,9 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aUse
|
|||
auto mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||
SetSizer( mainSizer );
|
||||
|
||||
m_infoBar = new WX_INFOBAR( this );
|
||||
mainSizer->Add( m_infoBar, 0, wxEXPAND, 0 );
|
||||
|
||||
m_treebook = new PAGED_TREEBOOK( this, wxID_ANY );
|
||||
mainSizer->Add( m_treebook, 1, wxEXPAND|wxLEFT|wxTOP, 10 );
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <project/project_file.h>
|
||||
#include <project/net_settings.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <widgets/infobar.h>
|
||||
#include "dialog_schematic_setup.h"
|
||||
#include "panel_eeschema_template_fieldnames.h"
|
||||
|
||||
|
@ -81,6 +82,9 @@ DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
|||
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
||||
|
||||
if( Prj().IsNullProject() )
|
||||
m_infoBar->ShowMessage( _( "No project is loaded. Changes will not be saved." ) );
|
||||
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
|
|
|
@ -284,10 +284,16 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
|
||||
if( differentProject )
|
||||
{
|
||||
GetSettingsManager()->SaveProject();
|
||||
if( !Prj().IsNullProject() )
|
||||
GetSettingsManager()->SaveProject();
|
||||
|
||||
Schematic().SetProject( nullptr );
|
||||
GetSettingsManager()->UnloadProject( &Prj() );
|
||||
GetSettingsManager()->LoadProject( pro.GetFullPath() );
|
||||
|
||||
// Do not load a project if one doesn't exist. This normally happens if we are
|
||||
// standalone and opening a board that has been moved from its project folder.
|
||||
GetSettingsManager()->LoadProject( pro.Exists() ? pro.GetFullPath() : "" );
|
||||
|
||||
CreateScreens();
|
||||
}
|
||||
|
||||
|
@ -622,7 +628,9 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
|
|||
|
||||
if( setProject )
|
||||
{
|
||||
GetSettingsManager()->SaveProject();
|
||||
if( !Prj().IsNullProject() )
|
||||
GetSettingsManager()->SaveProject();
|
||||
|
||||
Schematic().SetProject( nullptr );
|
||||
GetSettingsManager()->UnloadProject( &Prj() );
|
||||
|
||||
|
@ -777,7 +785,8 @@ bool SCH_EDIT_FRAME::SaveProject()
|
|||
sheets.emplace_back( std::make_pair( sheet->m_Uuid, sheet->GetName() ) );
|
||||
}
|
||||
|
||||
Pgm().GetSettingsManager().SaveProject();
|
||||
if( !Prj().IsNullProject() )
|
||||
Pgm().GetSettingsManager().SaveProject();
|
||||
|
||||
if( !Kiface().IsSingle() )
|
||||
{
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include <wx/treebook.h>
|
||||
|
||||
|
||||
class WX_INFOBAR;
|
||||
|
||||
|
||||
class PAGED_TREEBOOK : public wxTreebook
|
||||
{
|
||||
public:
|
||||
|
@ -89,6 +92,7 @@ protected:
|
|||
wxButton* m_auxiliaryButton;
|
||||
wxButton* m_resetButton;
|
||||
wxButton* m_cancelButton;
|
||||
WX_INFOBAR* m_infoBar;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <project.h>
|
||||
#include <project/project_file.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <widgets/infobar.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include "dialog_board_setup.h"
|
||||
|
@ -94,7 +95,10 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
|||
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
||||
|
||||
FinishDialogSettings();
|
||||
if( Prj().IsNullProject() )
|
||||
m_infoBar->ShowMessage( _( "No project is loaded. Changes will not be saved." ) );
|
||||
|
||||
FinishDialogSettings();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -519,12 +519,14 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
|||
|
||||
if( pro.GetFullPath() != mgr->Prj().GetProjectFullName() )
|
||||
{
|
||||
// calls SaveProject
|
||||
SaveProjectSettings();
|
||||
|
||||
mgr->SaveProject( mgr->Prj().GetProjectFullName() );
|
||||
mgr->UnloadProject( &mgr->Prj() );
|
||||
|
||||
mgr->LoadProject( pro.GetFullPath() );
|
||||
// Do not load a project if one doesn't exist. This normally happens if we are
|
||||
// standalone and opening a board that has been moved from its project folder.
|
||||
mgr->LoadProject( pro.Exists() ? pro.GetFullPath() : "" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -227,5 +227,6 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
|
|||
SELECTION_FILTER_OPTIONS& filterOpts = GetToolManager()->GetTool<SELECTION_TOOL>()->GetFilter();
|
||||
localSettings.m_SelectionFilter = filterOpts;
|
||||
|
||||
GetSettingsManager()->SaveProject();
|
||||
if( !Prj().IsNullProject() )
|
||||
GetSettingsManager()->SaveProject();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue