mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Fix compatibility with LCEDA/EasyEDA v2.2.32
Now device attributes can contain numbers. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18994
This commit is contained in:
parent
f09d274a3e
commit
840b9aebba
@ -307,3 +307,20 @@ EASYEDAPRO::ParseJsonLinesWithSeparation( wxInputStream& aInput, const wxString&
|
|||||||
|
|
||||||
return lineBlocks;
|
return lineBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::map<wxString, wxString>
|
||||||
|
EASYEDAPRO::AnyMapToStringMap( const std::map<wxString, nlohmann::json>& aInput )
|
||||||
|
{
|
||||||
|
std::map<wxString, wxString> stringMap;
|
||||||
|
|
||||||
|
for( auto& [key, value] : aInput )
|
||||||
|
{
|
||||||
|
if( value.is_string() )
|
||||||
|
stringMap[key] = value.get<wxString>();
|
||||||
|
else if( value.is_number() )
|
||||||
|
stringMap[key] = wxString::FromCDouble( value.get<double>() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringMap;
|
||||||
|
}
|
||||||
|
@ -63,6 +63,8 @@ std::vector<nlohmann::json> ParseJsonLines( wxInputStream& aInput, const wxStrin
|
|||||||
std::vector<std::vector<nlohmann::json>> ParseJsonLinesWithSeparation( wxInputStream& aInput,
|
std::vector<std::vector<nlohmann::json>> ParseJsonLinesWithSeparation( wxInputStream& aInput,
|
||||||
const wxString& aSource );
|
const wxString& aSource );
|
||||||
|
|
||||||
|
std::map<wxString, wxString> AnyMapToStringMap( const std::map<wxString, nlohmann::json>& aInput );
|
||||||
|
|
||||||
} // namespace EASYEDAPRO
|
} // namespace EASYEDAPRO
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <json_common.h>
|
#include <json_common.h>
|
||||||
#include <core/json_serializers.h>
|
#include <core/json_serializers.h>
|
||||||
#include <string_utils.h>
|
#include <string_utils.h>
|
||||||
|
#include <io/easyedapro/easyedapro_import_utils.h>
|
||||||
|
|
||||||
|
|
||||||
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::SCH_ATTR& d )
|
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::SCH_ATTR& d )
|
||||||
@ -273,7 +274,7 @@ void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::PRJ_DEVICE& d )
|
|||||||
d.custom_tags = j.at( "custom_tags" );
|
d.custom_tags = j.at( "custom_tags" );
|
||||||
|
|
||||||
if( j.at( "attributes" ).is_object() )
|
if( j.at( "attributes" ).is_object() )
|
||||||
d.attributes = j.at( "attributes" );
|
d.attributes = AnyMapToStringMap( j.at( "attributes" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::BLOB& d )
|
void EASYEDAPRO::from_json( const nlohmann::json& j, EASYEDAPRO::BLOB& d )
|
||||||
|
@ -1128,8 +1128,8 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
|||||||
if( !deviceAttr )
|
if( !deviceAttr )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::map<wxString, wxString> compAttrs =
|
std::map<wxString, wxString> compAttrs = EASYEDAPRO::AnyMapToStringMap(
|
||||||
aProject.at( "devices" ).at( deviceAttr->value ).at( "attributes" );
|
aProject.at( "devices" ).at( deviceAttr->value ).at( "attributes" ) );
|
||||||
|
|
||||||
wxString symbolId;
|
wxString symbolId;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user