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;
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
const wxString& aSource );
|
||||
|
||||
std::map<wxString, wxString> AnyMapToStringMap( const std::map<wxString, nlohmann::json>& aInput );
|
||||
|
||||
} // namespace EASYEDAPRO
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <json_common.h>
|
||||
#include <core/json_serializers.h>
|
||||
#include <string_utils.h>
|
||||
#include <io/easyedapro/easyedapro_import_utils.h>
|
||||
|
||||
|
||||
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" );
|
||||
|
||||
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 )
|
||||
|
@ -1128,8 +1128,8 @@ void SCH_EASYEDAPRO_PARSER::ParseSchematic( SCHEMATIC* aSchematic, SCH_SHEET* aR
|
||||
if( !deviceAttr )
|
||||
continue;
|
||||
|
||||
std::map<wxString, wxString> compAttrs =
|
||||
aProject.at( "devices" ).at( deviceAttr->value ).at( "attributes" );
|
||||
std::map<wxString, wxString> compAttrs = EASYEDAPRO::AnyMapToStringMap(
|
||||
aProject.at( "devices" ).at( deviceAttr->value ).at( "attributes" ) );
|
||||
|
||||
wxString symbolId;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user