Eeschema: fix root sheet UUID changing in project file.
This change is a bit more invasive than the description above would suggest. UUIDs have been added to all schematics. For now, it's only useful to the root schematic so that the UUID in the project file does not change every time the project file is save. In the future, it may be useful to store and check the schematic UUIDs against the one's saved in the project file. Fixes https://gitlab.com/kicad/code/kicad/issues/7763
This commit is contained in:
parent
211fd65c23
commit
df186a2049
|
@ -109,6 +109,10 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
|
||||||
if( !IsWritable( schematicFileName ) )
|
if( !IsWritable( schematicFileName ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// This is a new schematic file so make sure it has a unique ID.
|
||||||
|
if( aSaveUnderNewName )
|
||||||
|
screen->AssignNewUuid();
|
||||||
|
|
||||||
wxFileName tempFile( schematicFileName );
|
wxFileName tempFile( schematicFileName );
|
||||||
tempFile.SetName( wxT( "." ) + tempFile.GetName() );
|
tempFile.SetName( wxT( "." ) + tempFile.GetName() );
|
||||||
tempFile.SetExt( tempFile.GetExt() + wxT( "$" ) );
|
tempFile.SetExt( tempFile.GetExt() + wxT( "$" ) );
|
||||||
|
@ -853,7 +857,22 @@ bool SCH_EDIT_FRAME::SaveProject()
|
||||||
for( SCH_SHEET_PATH& sheetPath : Schematic().GetSheets() )
|
for( SCH_SHEET_PATH& sheetPath : Schematic().GetSheets() )
|
||||||
{
|
{
|
||||||
SCH_SHEET* sheet = sheetPath.Last();
|
SCH_SHEET* sheet = sheetPath.Last();
|
||||||
sheets.emplace_back( std::make_pair( sheet->m_Uuid, sheet->GetName() ) );
|
|
||||||
|
wxCHECK2( sheet, continue );
|
||||||
|
|
||||||
|
// Use the schematic UUID for the root sheet.
|
||||||
|
if( sheet->IsRootSheet() )
|
||||||
|
{
|
||||||
|
screen = sheet->GetScreen();
|
||||||
|
|
||||||
|
wxCHECK2( screen, continue );
|
||||||
|
|
||||||
|
sheets.emplace_back( std::make_pair( screen->GetUuid(), sheet->GetName() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sheets.emplace_back( std::make_pair( sheet->m_Uuid, sheet->GetName() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !Prj().IsNullProject() )
|
if( !Prj().IsNullProject() )
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2020 CERN
|
* Copyright (C) 2020-2021 CERN
|
||||||
*
|
*
|
||||||
* @author Wayne Stambaugh <stambaughw@gmail.com>
|
* @author Wayne Stambaugh <stambaughw@gmail.com>
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,6 @@
|
||||||
*
|
*
|
||||||
* @note Comment out the last version and add the new version as a date time stamp in the
|
* @note Comment out the last version and add the new version as a date time stamp in the
|
||||||
* YYYYMMDD format. Comment the changes to the file format for historical purposes.
|
* YYYYMMDD format. Comment the changes to the file format for historical purposes.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,4 +59,5 @@
|
||||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20201015 // Add sheet instance properties.
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20201015 // Add sheet instance properties.
|
||||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210123 // Rename "unconnected" pintype to "no_connect".
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210123 // Rename "unconnected" pintype to "no_connect".
|
||||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210125 // R/W uuids for pins, labels, wires, etc.
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210125 // R/W uuids for pins, labels, wires, etc.
|
||||||
#define SEXPR_SCHEMATIC_FILE_VERSION 20210126 // Fix bug with writing pin uuids.
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210126 // Fix bug with writing pin uuids.
|
||||||
|
#define SEXPR_SCHEMATIC_FILE_VERSION 20210406 // Add schematic level uuids.
|
||||||
|
|
|
@ -2046,6 +2046,12 @@ void SCH_SEXPR_PARSER::ParseSchematic( SCH_SHEET* aSheet, bool aIsCopyableOnly,
|
||||||
|
|
||||||
switch( token )
|
switch( token )
|
||||||
{
|
{
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
screen->m_uuid = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
case T_paper:
|
case T_paper:
|
||||||
{
|
{
|
||||||
if( aIsCopyableOnly )
|
if( aIsCopyableOnly )
|
||||||
|
|
|
@ -587,6 +587,8 @@ void SCH_SEXPR_PLUGIN::Format( SCH_SHEET* aSheet )
|
||||||
m_out->Print( 0, "(kicad_sch (version %d) (generator eeschema)\n\n",
|
m_out->Print( 0, "(kicad_sch (version %d) (generator eeschema)\n\n",
|
||||||
SEXPR_SCHEMATIC_FILE_VERSION );
|
SEXPR_SCHEMATIC_FILE_VERSION );
|
||||||
|
|
||||||
|
m_out->Print( 1, "(uuid %s)\n\n", TO_UTF8( screen->m_uuid.AsString() ) );
|
||||||
|
|
||||||
screen->GetPageSettings().Format( m_out, 1, 0 );
|
screen->GetPageSettings().Format( m_out, 1, 0 );
|
||||||
m_out->Print( 0, "\n" );
|
m_out->Print( 0, "\n" );
|
||||||
screen->GetTitleBlock().Format( m_out, 1, 0 );
|
screen->GetTitleBlock().Format( m_out, 1, 0 );
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <base_screen.h>
|
#include <base_screen.h>
|
||||||
#include <eda_item.h>
|
#include <eda_item.h>
|
||||||
#include <core/typeinfo.h>
|
#include <core/typeinfo.h>
|
||||||
|
#include <kiid.h>
|
||||||
#include <kiway_holder.h>
|
#include <kiway_holder.h>
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
#include <marker_base.h>
|
#include <marker_base.h>
|
||||||
|
@ -457,6 +458,10 @@ public:
|
||||||
return m_sheetInstances;
|
return m_sheetInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const KIID& GetUuid() const { return m_uuid; }
|
||||||
|
|
||||||
|
void AssignNewUuid() { m_uuid = KIID(); }
|
||||||
|
|
||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
void Show( int nestLevel, std::ostream& os ) const override;
|
void Show( int nestLevel, std::ostream& os ) const override;
|
||||||
#endif
|
#endif
|
||||||
|
@ -521,6 +526,14 @@ private:
|
||||||
*/
|
*/
|
||||||
std::vector<SYMBOL_INSTANCE_REFERENCE> m_symbolInstances;
|
std::vector<SYMBOL_INSTANCE_REFERENCE> m_symbolInstances;
|
||||||
std::vector<SCH_SHEET_INSTANCE> m_sheetInstances;
|
std::vector<SCH_SHEET_INSTANCE> m_sheetInstances;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique identifier for each schematic file.
|
||||||
|
*
|
||||||
|
* As of right now, this only has meaning for the root schematic. In the future, it may
|
||||||
|
* be useful to detect unexpected hierarchy changes.
|
||||||
|
*/
|
||||||
|
KIID m_uuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue