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/grid.h>
|
||||||
#include <wx/statline.h>
|
#include <wx/statline.h>
|
||||||
|
|
||||||
|
#include <widgets/infobar.h>
|
||||||
#include <widgets/paged_dialog.h>
|
#include <widgets/paged_dialog.h>
|
||||||
#include <wx/stc/stc.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 );
|
auto mainSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
SetSizer( mainSizer );
|
SetSizer( mainSizer );
|
||||||
|
|
||||||
|
m_infoBar = new WX_INFOBAR( this );
|
||||||
|
mainSizer->Add( m_infoBar, 0, wxEXPAND, 0 );
|
||||||
|
|
||||||
m_treebook = new PAGED_TREEBOOK( this, wxID_ANY );
|
m_treebook = new PAGED_TREEBOOK( this, wxID_ANY );
|
||||||
mainSizer->Add( m_treebook, 1, wxEXPAND|wxLEFT|wxTOP, 10 );
|
mainSizer->Add( m_treebook, 1, wxEXPAND|wxLEFT|wxTOP, 10 );
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <project/project_file.h>
|
#include <project/project_file.h>
|
||||||
#include <project/net_settings.h>
|
#include <project/net_settings.h>
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
|
#include <widgets/infobar.h>
|
||||||
#include "dialog_schematic_setup.h"
|
#include "dialog_schematic_setup.h"
|
||||||
#include "panel_eeschema_template_fieldnames.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,
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||||
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
||||||
|
|
||||||
|
if( Prj().IsNullProject() )
|
||||||
|
m_infoBar->ShowMessage( _( "No project is loaded. Changes will not be saved." ) );
|
||||||
|
|
||||||
FinishDialogSettings();
|
FinishDialogSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,10 +284,16 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
if( differentProject )
|
if( differentProject )
|
||||||
{
|
{
|
||||||
|
if( !Prj().IsNullProject() )
|
||||||
GetSettingsManager()->SaveProject();
|
GetSettingsManager()->SaveProject();
|
||||||
|
|
||||||
Schematic().SetProject( nullptr );
|
Schematic().SetProject( nullptr );
|
||||||
GetSettingsManager()->UnloadProject( &Prj() );
|
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();
|
CreateScreens();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +628,9 @@ void SCH_EDIT_FRAME::OnImportProject( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
if( setProject )
|
if( setProject )
|
||||||
{
|
{
|
||||||
|
if( !Prj().IsNullProject() )
|
||||||
GetSettingsManager()->SaveProject();
|
GetSettingsManager()->SaveProject();
|
||||||
|
|
||||||
Schematic().SetProject( nullptr );
|
Schematic().SetProject( nullptr );
|
||||||
GetSettingsManager()->UnloadProject( &Prj() );
|
GetSettingsManager()->UnloadProject( &Prj() );
|
||||||
|
|
||||||
|
@ -777,6 +785,7 @@ bool SCH_EDIT_FRAME::SaveProject()
|
||||||
sheets.emplace_back( std::make_pair( sheet->m_Uuid, sheet->GetName() ) );
|
sheets.emplace_back( std::make_pair( sheet->m_Uuid, sheet->GetName() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !Prj().IsNullProject() )
|
||||||
Pgm().GetSettingsManager().SaveProject();
|
Pgm().GetSettingsManager().SaveProject();
|
||||||
|
|
||||||
if( !Kiface().IsSingle() )
|
if( !Kiface().IsSingle() )
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#include <wx/treebook.h>
|
#include <wx/treebook.h>
|
||||||
|
|
||||||
|
|
||||||
|
class WX_INFOBAR;
|
||||||
|
|
||||||
|
|
||||||
class PAGED_TREEBOOK : public wxTreebook
|
class PAGED_TREEBOOK : public wxTreebook
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -89,6 +92,7 @@ protected:
|
||||||
wxButton* m_auxiliaryButton;
|
wxButton* m_auxiliaryButton;
|
||||||
wxButton* m_resetButton;
|
wxButton* m_resetButton;
|
||||||
wxButton* m_cancelButton;
|
wxButton* m_cancelButton;
|
||||||
|
WX_INFOBAR* m_infoBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <project.h>
|
#include <project.h>
|
||||||
#include <project/project_file.h>
|
#include <project/project_file.h>
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
|
#include <widgets/infobar.h>
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
|
|
||||||
#include "dialog_board_setup.h"
|
#include "dialog_board_setup.h"
|
||||||
|
@ -94,6 +95,9 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
||||||
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
||||||
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
||||||
|
|
||||||
|
if( Prj().IsNullProject() )
|
||||||
|
m_infoBar->ShowMessage( _( "No project is loaded. Changes will not be saved." ) );
|
||||||
|
|
||||||
FinishDialogSettings();
|
FinishDialogSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -519,12 +519,14 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
|
|
||||||
if( pro.GetFullPath() != mgr->Prj().GetProjectFullName() )
|
if( pro.GetFullPath() != mgr->Prj().GetProjectFullName() )
|
||||||
{
|
{
|
||||||
|
// calls SaveProject
|
||||||
SaveProjectSettings();
|
SaveProjectSettings();
|
||||||
|
|
||||||
mgr->SaveProject( mgr->Prj().GetProjectFullName() );
|
|
||||||
mgr->UnloadProject( &mgr->Prj() );
|
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();
|
SELECTION_FILTER_OPTIONS& filterOpts = GetToolManager()->GetTool<SELECTION_TOOL>()->GetFilter();
|
||||||
localSettings.m_SelectionFilter = filterOpts;
|
localSettings.m_SelectionFilter = filterOpts;
|
||||||
|
|
||||||
|
if( !Prj().IsNullProject() )
|
||||||
GetSettingsManager()->SaveProject();
|
GetSettingsManager()->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue