From 97a9f43a9fa65de73fa2872da61a34f6b07d35e4 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 27 Dec 2020 12:12:24 -0500 Subject: [PATCH] Fix import of schematic grid settings Fixes https://gitlab.com/kicad/code/kicad/-/issues/6705 --- eeschema/eeschema_settings.cpp | 15 +++++++++++++++ eeschema/symbol_editor/symbol_editor_settings.cpp | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/eeschema/eeschema_settings.cpp b/eeschema/eeschema_settings.cpp index f3be6ee998..fded693786 100644 --- a/eeschema/eeschema_settings.cpp +++ b/eeschema/eeschema_settings.cpp @@ -358,6 +358,21 @@ bool EESCHEMA_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) { bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); + // Now modify the loaded grid selection, because in earlier versions the grids index was shared + // between all applications and started at 1000 mils. There is a 4-position offset between + // this index and the possible eeschema grids list that we have to subtract. + nlohmann::json::json_pointer gridSizePtr = PointerFromString( "window.grid.last_size" ); + + try + { + ( *this )[gridSizePtr] = ( *this )[gridSizePtr].get() - 4; + } + catch( ... ) + { + // Otherwise, default grid size should be 50 mils; index 1 + ( *this )[gridSizePtr] = 1; + } + ret &= fromLegacy( aCfg, "FootprintPreview", "appearance.footprint_preview" ); ret &= fromLegacy( aCfg, "NavigatorStaysOpen", "appearance.navigator_stays_open" ); ret &= fromLegacy( aCfg, "PrintSheetReferenceAndTitleBlock", diff --git a/eeschema/symbol_editor/symbol_editor_settings.cpp b/eeschema/symbol_editor/symbol_editor_settings.cpp index 1169659bc6..dec5c5b9c1 100644 --- a/eeschema/symbol_editor/symbol_editor_settings.cpp +++ b/eeschema/symbol_editor/symbol_editor_settings.cpp @@ -89,6 +89,21 @@ bool SYMBOL_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) { bool ret = APP_SETTINGS_BASE::MigrateFromLegacy( aCfg ); + // Now modify the loaded grid selection, because in earlier versions the grids index was shared + // between all applications and started at 1000 mils. There is a 4-position offset between + // this index and the possible eeschema grids list that we have to subtract. + nlohmann::json::json_pointer gridSizePtr = PointerFromString( "window.grid.last_size" ); + + try + { + ( *this )[gridSizePtr] = ( *this )[gridSizePtr].get() - 4; + } + catch( ... ) + { + // Otherwise, default grid size should be 50 mils; index 1 + ( *this )[gridSizePtr] = 1; + } + ret &= fromLegacy( aCfg, "DefaultWireWidth", "defaults.line_width" ); ret &= fromLegacy( aCfg, "DefaultPinLength", "defaults.pin_length" ); ret &= fromLegacy( aCfg, "LibeditPinNameSize", "defaults.pin_name_size" );