From 55d2d0d93e03190223a64d23b655e4131cbbfd82 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 13 Apr 2021 13:33:02 +0100 Subject: [PATCH] Fix some bugs in file save as. The order of operations *appeared* to be a bit out of joint. We need to create a new project in project mode as well as in standalone. Fixes https://gitlab.com/kicad/code/kicad/issues/8143 --- pcbnew/files.cpp | 25 ++++++++++++++++++------- pcbnew/pcb_painter.cpp | 2 +- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index fd1c804e82..4fa5691d73 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -264,7 +264,7 @@ bool AskSaveBoardFileName( PCB_EDIT_FRAME* aParent, wxString* aFileName, bool* a if( wxWindow* extraControl = dlg.GetExtraControl() ) *aCreateProject = static_cast( extraControl )->GetValue(); - else if( Kiface().IsSingle() && !aParent->Prj().IsNullProject() ) + else if( !aParent->Prj().IsNullProject() ) *aCreateProject = true; return true; @@ -951,8 +951,12 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory, // If no project to load then initialize project text vars with board properties if( !mgr->LoadProject( projectFile.GetFullPath() ) ) + { Prj().GetTextVars() = GetBoard()->GetProperties(); + // TODO: save netclasses from currentProject to new project... + } + GetBoard()->SetProject( &Prj() ); } } @@ -1107,21 +1111,28 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName, bool aCreateProject SETTINGS_MANAGER* mgr = GetSettingsManager(); + // Shelve the current project GetBoard()->ClearProject(); mgr->SaveProject( currentProject ); mgr->UnloadProject( &Prj() ); - mgr->LoadProject( projectFile.GetFullPath() ); - mgr->SaveProject(); - - mgr->UnloadProject( &Prj() ); - mgr->LoadProject( currentProject ); + // Create a new project for the saved-as-copy // If no project to load then initialize project text vars with board properties - if( !mgr->LoadProject( currentProject ) ) + if( !mgr->LoadProject( projectFile.GetFullPath() ) ) + { Prj().GetTextVars() = GetBoard()->GetProperties(); + // TODO: save netclasses from currentProject to new project... + } + + mgr->SaveProject(); + + // Now go back to our own project + mgr->UnloadProject( &Prj() ); + mgr->LoadProject( currentProject ); + GetBoard()->SetProject( &Prj() ); } } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 18293a1af1..5c04bcb166 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -332,7 +332,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons } // Apply high-contrast dimming - if( m_hiContrastEnabled && !highlighted && !selected ) + if( m_hiContrastEnabled && m_highContrastLayers.size() && !highlighted && !selected ) { PCB_LAYER_ID primary = GetPrimaryHighContrastLayer(); bool isActive = m_highContrastLayers.count( aLayer );