diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp index 209c029556..fc7ceb04cc 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp @@ -21,6 +21,7 @@ #include <3d_enums.h> #include #include +#include #include #include "eda_3d_viewer_settings.h" @@ -28,7 +29,7 @@ using KIGFX::COLOR4D; ///! Update the schema version whenever a migration is required -const int viewer3dSchemaVersion = 0; +const int viewer3dSchemaVersion = 1; EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() @@ -169,7 +170,8 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() &m_Render.show_board_body, true ) ); m_params.emplace_back( new PARAM( "render.show_comments", &m_Render.show_comments, true ) ); - m_params.emplace_back( new PARAM( "render.show_eco", &m_Render.show_eco, true ) ); + m_params.emplace_back( new PARAM( "render.show_eco", + &m_Render.show_eco, true ) ); m_params.emplace_back( new PARAM( "render.show_footprints_insert", &m_Render.show_footprints_insert, true ) ); m_params.emplace_back( new PARAM( "render.show_footprints_normal", @@ -199,7 +201,27 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() m_params.emplace_back( new PARAM( "camera.projection_mode", &m_Camera.projection_mode, 1 ) ); - m_params.emplace_back( new PARAM_OBSOLETE( "colors" ) ); + registerMigration( 0, 1, std::bind( &EDA_3D_VIEWER_SETTINGS::migrateSchema0to1, this ) ); +} + + +bool EDA_3D_VIEWER_SETTINGS::migrateSchema0to1() +{ + /** + * Schema version 0 to 1: + * + * delete colors (they're now stored in the 'user' color theme. + */ + try + { + if( m_internals->contains( "colors" ) ) + m_internals->erase( "colors" ); + } + catch( ... ) + { + } + + return true; } diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_settings.h b/3d-viewer/3d_viewer/eda_3d_viewer_settings.h index fd36bae3a5..455dc2da18 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_settings.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer_settings.h @@ -106,8 +106,10 @@ public: CAMERA_SETTINGS m_Camera; protected: - virtual std::string getLegacyFrameName() const override { return "Viewer3DFrameName"; } + +private: + bool migrateSchema0to1(); }; diff --git a/common/settings/parameters.cpp b/common/settings/parameters.cpp index 0a31441fcd..c00c02967f 100644 --- a/common/settings/parameters.cpp +++ b/common/settings/parameters.cpp @@ -25,13 +25,6 @@ #include #include #include -#include - - -void PARAM_OBSOLETE::Store( JSON_SETTINGS* aSettings ) const -{ - aSettings->Internals()->erase( m_path ); -} template diff --git a/include/settings/parameters.h b/include/settings/parameters.h index 9e540031fb..002b454398 100644 --- a/include/settings/parameters.h +++ b/include/settings/parameters.h @@ -156,30 +156,6 @@ protected: ValueType m_default; }; -/** - * Handles an obsolete parameter (ie: removes it on write). - */ -class PARAM_OBSOLETE : public PARAM_BASE -{ -public: - PARAM_OBSOLETE( const std::string& aJsonPath ) : - PARAM_BASE( aJsonPath, false ) - { } - - void Load( JSON_SETTINGS* aSettings, bool aResetIfMissing = true ) const override - { } - - void Store( JSON_SETTINGS* aSettings ) const override; - - void SetDefault() override - { } - - bool MatchesFile( JSON_SETTINGS* aSettings ) const override - { - return !aSettings->Contains( m_path ); - } -}; - /** * Stores a path as a string with directory separators normalized to unix-style */