FP editor: use the footprint datasheet field value if it is not empty.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21149
This commit is contained in:
jean-pierre charras
2025-06-17 18:02:40 +02:00
parent af076488f5
commit c56d55b3e7
+11 -3
View File
@@ -47,11 +47,18 @@ static const wxString DocFormat = wxT(
std::optional<wxString> GetFootprintDocumentationURL( const FOOTPRINT& aFootprint )
{
// Footprints have now a field (FIELD_T::DATASHEET) containing the url datasheet
// But old footprints did not have this field, so this fiels can be empty.
// So we use this field is not empty, and if empty see if the documentation has an URL
const PCB_FIELD* data_field = aFootprint.GetField( FIELD_T::DATASHEET );
wxString url = data_field->GetText();
if( !url.IsEmpty() )
return url;
wxString desc = aFootprint.GetLibDescription();
wxString url;
// It is currently common practice to store a documentation link in the description.
// It is (or was) currently common practice to store a documentation link in the description.
size_t idx = desc.find( wxT( "http:" ) );
if( idx == wxString::npos )
@@ -87,6 +94,7 @@ std::optional<wxString> GetFootprintDocumentationURL( const FOOTPRINT& aFootprin
if( url.IsEmpty() )
return std::nullopt;
return url;
}