Assert if NESTED_SETTINGS migration is missing for an intermediate version
- Fixes early load during NESTED_SETTINGS construction within SCHEMATIC_SETTINGS, now failing due to missing migrations at that object construction point - Adds missing (NOOP) migration for NET_SETTINGS schema versions 1 -> 2
This commit is contained in:
parent
89433afb47
commit
658eb1d338
|
@ -54,7 +54,7 @@ static int getInSchUnits( const nlohmann::json& aObj, const std::string& aKey, i
|
|||
|
||||
|
||||
NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
||||
NESTED_SETTINGS( "net_settings", netSettingsSchemaVersion, aParent, aPath )
|
||||
NESTED_SETTINGS( "net_settings", netSettingsSchemaVersion, aParent, aPath, false )
|
||||
{
|
||||
m_DefaultNetClass = std::make_shared<NETCLASS>( NETCLASS::Default );
|
||||
m_DefaultNetClass->SetDescription( _( "This is the default net class." ) );
|
||||
|
@ -298,6 +298,7 @@ NET_SETTINGS::NET_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
|||
{} ) );
|
||||
|
||||
registerMigration( 0, 1, std::bind( &NET_SETTINGS::migrateSchema0to1, this ) );
|
||||
registerMigration( 1, 2, std::bind( &NET_SETTINGS::migrateSchema1to2, this ) );
|
||||
registerMigration( 2, 3, std::bind( &NET_SETTINGS::migrateSchema2to3, this ) );
|
||||
}
|
||||
|
||||
|
@ -360,6 +361,12 @@ bool NET_SETTINGS::migrateSchema0to1()
|
|||
}
|
||||
|
||||
|
||||
bool NET_SETTINGS::migrateSchema1to2()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool NET_SETTINGS::migrateSchema2to3()
|
||||
{
|
||||
if( m_internals->contains( "classes" ) && m_internals->At( "classes" ).is_array() )
|
||||
|
|
|
@ -674,29 +674,29 @@ bool JSON_SETTINGS::Migrate()
|
|||
|
||||
while( filever < m_schemaVersion )
|
||||
{
|
||||
wxASSERT( m_migrators.count( filever ) > 0 );
|
||||
|
||||
if( !m_migrators.count( filever ) )
|
||||
{
|
||||
wxLogTrace( traceSettings, wxT( "Migrator missing for %s version %d!" ),
|
||||
typeid( *this ).name(), filever );
|
||||
filever++;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<int, std::function<bool()>> pair = m_migrators.at( filever );
|
||||
|
||||
if( pair.second() )
|
||||
{
|
||||
wxLogTrace( traceSettings, wxT( "Migrated %s from %d to %d" ), typeid( *this ).name(),
|
||||
filever, pair.first );
|
||||
filever = pair.first;
|
||||
m_internals->At( "meta.version" ) = filever;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::pair<int, std::function<bool()>> pair = m_migrators.at( filever );
|
||||
|
||||
if( pair.second() )
|
||||
{
|
||||
wxLogTrace( traceSettings, wxT( "Migrated %s from %d to %d" ),
|
||||
typeid( *this ).name(), filever, pair.first );
|
||||
filever = pair.first;
|
||||
m_internals->At( "meta.version" ) = filever;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogTrace( traceSettings, wxT( "Migration failed for %s from %d to %d" ),
|
||||
typeid( *this ).name(), filever, pair.first );
|
||||
return false;
|
||||
}
|
||||
wxLogTrace( traceSettings, wxT( "Migration failed for %s from %d to %d" ),
|
||||
typeid( *this ).name(), filever, pair.first );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
|
||||
NESTED_SETTINGS::NESTED_SETTINGS( const std::string& aName, int aVersion, JSON_SETTINGS* aParent,
|
||||
const std::string& aPath ) :
|
||||
const std::string& aPath, bool aLoadFromFile ) :
|
||||
JSON_SETTINGS( aName, SETTINGS_LOC::NESTED, aVersion ),
|
||||
m_parent( aParent ), m_path( aPath )
|
||||
{
|
||||
SetParent( aParent );
|
||||
SetParent( aParent, aLoadFromFile );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ const int schSettingsSchemaVersion = 1;
|
|||
|
||||
|
||||
SCHEMATIC_SETTINGS::SCHEMATIC_SETTINGS( JSON_SETTINGS* aParent, const std::string& aPath ) :
|
||||
NESTED_SETTINGS( "schematic", schSettingsSchemaVersion, aParent, aPath ),
|
||||
NESTED_SETTINGS( "schematic", schSettingsSchemaVersion, aParent, aPath, false ),
|
||||
m_DefaultLineWidth( DEFAULT_LINE_WIDTH_MILS * schIUScale.IU_PER_MILS ),
|
||||
m_DefaultTextSize( DEFAULT_TEXT_SIZE * schIUScale.IU_PER_MILS ),
|
||||
m_LabelSizeRatio( DEFAULT_LABEL_SIZE_RATIO ),
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
|
||||
private:
|
||||
bool migrateSchema0to1();
|
||||
bool migrateSchema1to2();
|
||||
bool migrateSchema2to3();
|
||||
|
||||
// TODO: Add diff pairs, bus information, etc.
|
||||
|
|
|
@ -32,7 +32,7 @@ class KICOMMON_API NESTED_SETTINGS : public JSON_SETTINGS
|
|||
{
|
||||
public:
|
||||
NESTED_SETTINGS( const std::string& aName, int aSchemaVersion, JSON_SETTINGS* aParent,
|
||||
const std::string& aPath );
|
||||
const std::string& aPath, bool aLoadFromFile = true );
|
||||
|
||||
virtual ~NESTED_SETTINGS();
|
||||
|
||||
|
|
Loading…
Reference in New Issue