Update schema versions so we can patch bad data from earlier bug.

Fixes https://gitlab.com/kicad/code/kicad/issues/12180
This commit is contained in:
Jeff Young 2022-08-15 23:43:42 +01:00
parent e015f5b086
commit a3dc38cb32
3 changed files with 33 additions and 10 deletions

View File

@ -42,7 +42,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
m_appSettingsSchemaVersion( aSchemaVersion ) m_appSettingsSchemaVersion( aSchemaVersion )
{ {
// Make Coverity happy: // Make Coverity happy:
m_LibTree.column_width = 360; m_LibTree.column_width = 300;
m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_FALLBACK; m_Graphics.canvas_type = EDA_DRAW_PANEL_GAL::GAL_FALLBACK;
// Build parameters list: // Build parameters list:
@ -73,13 +73,7 @@ APP_SETTINGS_BASE::APP_SETTINGS_BASE( const std::string& aFilename, int aSchemaV
&m_ColorPicker.default_tab, 0 ) ); &m_ColorPicker.default_tab, 0 ) );
m_params.emplace_back( new PARAM<int>( "lib_tree.column_width", m_params.emplace_back( new PARAM<int>( "lib_tree.column_width",
&m_LibTree.column_width, 360 ) ); &m_LibTree.column_width, 300 ) );
// Now that we allow hiding/showing of the tree control, it's never terribly useful to
// decrease the width to nothing, and wxWidgets appears to have some bugs where it sets it
// way too narrow.
if( m_LibTree.column_width < 360 )
m_LibTree.column_width = 360;
m_params.emplace_back( new PARAM<bool>( "printing.background", m_params.emplace_back( new PARAM<bool>( "printing.background",
&m_Printing.background, false ) ); &m_Printing.background, false ) );

View File

@ -40,7 +40,7 @@
using namespace T_BOMCFG_T; // for the BOM_CFG_PARSER parser and its keywords using namespace T_BOMCFG_T; // for the BOM_CFG_PARSER parser and its keywords
///! Update the schema version whenever a migration is required ///! Update the schema version whenever a migration is required
const int eeschemaSchemaVersion = 1; const int eeschemaSchemaVersion = 2;
/// Default value for bom.plugins /// Default value for bom.plugins
const nlohmann::json defaultBomPlugins = const nlohmann::json defaultBomPlugins =
@ -446,6 +446,21 @@ EESCHEMA_SETTINGS::EESCHEMA_SETTINGS() :
// Version 0 to 1: BOM plugin settings moved from sexpr to JSON // Version 0 to 1: BOM plugin settings moved from sexpr to JSON
return migrateBomSettings(); return migrateBomSettings();
} ); } );
registerMigration( 1, 2,
[&]() -> bool
{
// We used to have a bug on GTK which would set the lib tree column width way
// too narrow.
if( OPT<int> optval = Get<int>( "lib_tree.column_width" ) )
{
if( optval < 150 )
Set( "lib_tree.column_width", 300 );
}
return true;
} );
} }

View File

@ -43,7 +43,7 @@
///! Update the schema version whenever a migration is required ///! Update the schema version whenever a migration is required
const int pcbnewSchemaVersion = 2; const int pcbnewSchemaVersion = 3;
PCBNEW_SETTINGS::PCBNEW_SETTINGS() PCBNEW_SETTINGS::PCBNEW_SETTINGS()
@ -578,6 +578,20 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS()
return true; return true;
} ); } );
registerMigration( 2, 3,
[&]() -> bool
{
// We used to have a bug on GTK which would set the lib tree column width way
// too narrow.
if( OPT<int> optval = Get<int>( "lib_tree.column_width" ) )
{
if( optval < 150 )
Set( "lib_tree.column_width", 300 );
}
return true;
} );
} }