380 Commits

Author SHA1 Message Date
Jon Evans 683bb74b7f Reduce memory usage of FOOTPRINT caches
These aren't needed until a footprint is materialized
2026-03-19 21:25:34 -04:00
Jon Evans 1637a124ff API: always serialize with UTF-8 2026-03-15 22:02:55 -04:00
John Beard c8b2bef4f5 Pcbnew: preserve courtyard cache on Flip and Rotate
This isn't a major hotspot, but Flip does show up a little on
a profile of board loading, so it not nothing, and it's quite
easy to maintain the existing geometry here.

Also maintains the hull on rotation.

And add some tests around the courtyard and hull class invariants.
2026-03-08 00:53:34 +08:00
John Beard c4c19018c3 Pcbnew: Restrict includes of pad.h/footprint.h
There are some headers which don't need to include pad.h (which brings
padstack.h) - they just need forward defines.

While pad.h is not an especially heavy include on the scale of things,
footprint is quite heavy. And both reduce inclusion load and
reduce the number of files needlessly sensitive to changes in headers.
2026-03-05 02:18:34 +08:00
Jon Evans f06a303384 Symbol chooser performance improvements
Cache LIB_SYMBOL properties used for chooser filtering
Reduce copying during creation of chooser widgets

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23267
2026-03-03 21:26:07 -05:00
Jeff Young 5907823cfb Make PCB editor message panel variant-aware. 2026-02-23 14:41:58 +00:00
Jeff Young bdd64f8da3 Separate footprint properties from fields.
The PCB_FOOTPRINT_FIELD_PROPERTYs only get created
when there's a GUI.
2026-02-22 23:00:34 +00:00
Damjan Prerad d3b80988d4 Register footprint properties in FOOTPRINT_DESC for non-GUI QA tests
7b7fc35c9c moved Library Link, Library Description, Keywords, and
Component Class property registrations from FOOTPRINT_DESC to
PCB_PROPERTIES_PANEL::rebuildProperties() for display ordering.
rebuildProperties() only runs in the GUI so these properties
were not being registered in non GUI QA tests

This commit moves them back to FOOTPRINT_DESC
The Value property remains in rebuildProperties() for variant support
2026-02-22 23:35:58 +01:00
Jeff Young d7761d08c2 Better reporting when multiple footprints share the same RefDes.
Also guards access to fields in variant m_fields map.
2026-02-22 20:05:47 +00:00
Seth Hillbrand 7cbcf99249 Fix crash importing Allegro with bad layer IDs
The Allegro importer can produce out-of-range layer values
when non-ETCH layer classes share the copper layer list
pointer but have subclass indices beyond the copper layer
count. Add a bounds check in GetLayer() so these fall
through to the custom layer mapping instead of feeding
large values into getNthCopperLayer(). Also guard the
LSET::test() calls in FOOTPRINT against invalid layers
to prevent the dynamic_bitset assertion failure that
caused the crash.
2026-02-20 16:13:19 -08:00
Jeff Young 7b7fc35c9c Move value property to PCB_FOOTPRINT_FIELD_PROPERTY.
(Also reworks things a little to give the fields a
more expected order.)
2026-02-20 18:56:52 +00:00
Seth Hillbrand 4aca084ab0 Remove heavy includes from board.h and footprint.h PCH chain
Remove component_class_manager.h and pcb_selection.h from board.h

Remove collectors.h and component_class_manager.h from footprint.h
2026-02-13 19:54:46 -08:00
Seth Hillbrand 6c9c75eb07 Remove property.h and property_mgr.h from inspectable.h
This breaks the view_item.h -> inspectable.h -> property.h chain that
pulled wx/propgrid/property.h into 150-200 TUs. The lean inspectable.h
now includes only wx/any.h, wx/string.h, wx/variant.h.

Headers using DECLARE_ENUM_TO_WXANY (board_item.h, sch_item.h) retain
their property.h include since the macro requires it.
2026-02-13 19:54:46 -08:00
Seth Hillbrand f62118b095 Fix m_itemByIdCache synchronization issues
The item-by-id cache was not being updated when footprint children
were added, removed, or replaced. This caused stale cache entries
pointing to freed memory and missing entries requiring slow linear
search fallback.

Add CacheItemById and UncacheItemById methods to BOARD. Update
FOOTPRINT::Add and FOOTPRINT::Remove to call these when the footprint
is on a board. Fix the footprint properties dialog, Deserialize, and
assignment operators to uncache items before deleting them.

Also remove the spurious m_itemByIdCache check from IncrementTimeStamp
since this cache is managed by Add/Remove operations and should not be
cleared on timestamp increment.
2026-01-29 10:54:57 -08:00
Seth Hillbrand 764cfdd3ba Remove fp-info-cache and simplify footprint library loading
Tree adapters now call GetFootprints() directly instead of going through
GFootprintList and its cache file. FOOTPRINT implements LIB_TREE_ITEM so
footprint objects work directly in library tree displays similar to
LIB_SYMBOL.

Removed cache read/write calls from files.cpp, footprint_edit_frame.cpp,
and pcb_base_edit_frame.cpp. The footprint chooser uses AsyncLoad() and
BlockUntilLoaded() to ensure libraries are ready before building trees.

GFootprintList still exists for cvpcb and eeschema cross-module access
via KIWAY, but no longer reads or writes cache files.
2026-01-23 08:44:31 -08:00
Seth Hillbrand d85dcd1779 Fix multiple ThreadSanitizer data races
- Make arc_tolerance_factor arrays thread_local in SHAPE_POLY_SET::inflate2
and inflateLine2 to avoid races during parallel zone filling.

- Remove redundant m_maxError assignment in ZONE_FILLER::fillCopperZone
since it's already initialized in the constructor. This prevents multiple
threads from writing to the member variable concurrently.

- Add mutex protection to FOOTPRINT::GetBoundingBox to synchronize cache
access when multiple threads compute bounding boxes concurrently.
2026-01-20 21:48:44 -08:00
Seth Hillbrand 7a74a7fc65 Fix missing initialization
m_componentClassCacheProxy was missing its init, so the assignment
operator didn't have a valid unique_ptr and got null

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22673
2026-01-08 16:11:04 -08:00
Seth Hillbrand 127a85f753 Fix component classes not being cleared during Update PCB from Schematic
Two things were happening here

1. The FOOTPRINT copy constructor and assignment operators did not copy
the static component class from the source footprint. So when the undo
system created copies of footprints, the component class information was lost.

2. When only the component class changed (no other footprint parameters), the
change was not recorded in the commit and could be lost.

This change adds the component class info to the copy operation, tracks
it in COMMIT and updates footprins without component classes to 'none'

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21101
2026-01-06 04:28:00 -08:00
Seth Hillbrand e0633ea9ce Fix memory leak in FOOTPRINT
We had some copy/pasta in the points group and lost dangling pointers
from a move operation.  Potentially a cause of heap corruption

Also set the parser to skip null fields on load

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22623
2026-01-05 18:38:48 -08:00
Seth Hillbrand 6bad3c58e1 Added: PCB Variant support
Fixes https://gitlab.com/kicad/code/kicad/-/issues/2131
2026-01-05 17:47:39 -08:00
Alex Shvartzkop 3b53339938 Fix UNDEFINED_LAYER condition in TransformFPShapesToPolySet. 2025-12-20 02:20:30 +03:00
Mike Williams 8f0a3ae776 footprint anchors: only show them for footprints on visible layers 2025-12-11 08:28:34 -05:00
Mark Roszko d6bea496f4 Update pad layers on footprint swap dialog, centralize that function from the pcb parser 2025-12-06 12:17:08 -05:00
Mark Roszko 8cdbe24011 Fix warning over a pointless cast 2025-12-01 18:24:33 -05:00
Mark Roszko ca946dd35f Fix build due to f5a06463d5 2025-11-22 12:42:24 -05:00
Jon Evans f5a06463d5 API: Fix serialization of footprint rule overrides; add missing allow_soldermask_bridges attribute
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21674


(cherry picked from commit ea5ae7cc5d)

Co-authored-by: Jon Evans <jon@craftyjon.com>
2025-11-22 09:59:21 -05:00
Jon Evans a9ac108152 API: Preserve linked symbol properties in footprints
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21655


(cherry picked from commit 949be9a63a)

Co-authored-by: Jon Evans <jon@craftyjon.com>
2025-11-20 19:57:50 -05:00
Jeff Young 607a39be27 Adding/removing items to/from footprint taints the geometry caches.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/22203
2025-11-04 17:54:33 +00:00
Jeff Young 943b2fdcac Don't use std::ranges::copy for set-equal.
It's harder to read, and if you forget to clear the
destination first, it won't do what you expect.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22161
2025-10-30 11:33:27 +00:00
Seth Hillbrand 18a62544e9 Added default properties panel for footprint and symbol
When nothing is selected in the footprint and symbol editors, we show
the properties of the footprint and symbol, allowing easy access to
their properties
2025-10-03 13:13:29 -07:00
Jeff Young 507b22bbaf Fill in more missing barcode code. 2025-10-02 21:52:43 +01:00
Jeff Young 2fe7219474 Support translation in tool context menus that are long-lived.
(The specialized ones are OK as they're created
for each use.)

Also, enum maps must be untranslated.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21859
2025-10-01 00:03:45 +01:00
Seth Hillbrand 4a74153315 Updating barcode support
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4393
2025-09-26 11:35:36 -07:00
Jeff Young 87739c8ac7 wxStringTokenizer usage cleanup.
1) Always be explicit about what the delimiters are
2) If space is a delimiter, we probably want to skip
empty fields (wxTOKEN_STRTOK)
3) If space is not a delimiter, we often need to
trim the resultant tokens
4) Be more lenient about \t\r\n (and when they are
included, include them in the same order)
2025-09-16 13:03:02 +01:00
Seth Hillbrand 826f15a103 Prevent crash in nettie
We need to avoid collecting invalid layers in the net ties regardless of
their origins
2025-09-02 19:18:58 -07:00
John Beard e016dc52fd Pcbnew: Add concept of a 'point'
This is a zero-dimensional object that can be used for snapping
and documentation of useful, but non-physical features on a
board or footprint. They do not correspond to any physical
output in exports or plots.

Points do have a "size", but this is a graphical property only
and determines how large they are drawn on the board.

They also have a layer, which allows them to be selected and
made visible according to layer filters.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/4691
2025-09-01 23:44:21 +08:00
John Beard c4d9338097 Pcbnew: sort sexpr text items stably
Currently all texts on the same layer do not sort stably in the file
format. Add sorting criteria to sort by position, angle, size
and so on and finally by string.
2025-09-01 23:44:21 +08:00
Jeff Young c6fcf7e0b8 Allow easier code searching for property names. 2025-08-30 19:09:15 +01:00
Jeff Young c287d9a222 Avoid div-by-zero. 2025-08-19 13:42:49 +01:00
John Beard ed01324c1d Footprints: allow to set specific internal copper layers
Footprints can now have a custom stackup. This means that they specify
an exact number of copper layers and the layers map 1:1 to board layers.
If the board doesn't contain that layer, the element just doesn't
show. We could make this a DRC check later on.

If there is no stackup, the behavior is the current default: a rule area
the In1 layer "expands" to all Inner layers.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/10838
2025-08-19 04:59:48 +08:00
jean-pierre charras 09e1fca7e4 More about support of press-fit pad fabrication property
Also some fixes in dialogs.
2025-08-11 18:48:35 +02:00
Andrzej Wolski c73d555fe2 ADDED: Lasso selection in pcbnew
Adds a lasso or freeform selection tool to KiCad in addition to standard
rectangular selection.  Adds supporting HitTest routines

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/1977
2025-08-06 16:06:40 -07:00
Jeff Young 7240128130 Formatting. 2025-08-04 19:11:59 +01:00
Jeff Young a8df4b16e2 Range checking. 2025-08-03 20:32:19 +01:00
Jeff Young c758a2fbaf Don't sequence layers when order doesn't matter. 2025-07-14 19:12:44 +01:00
Jeff Young 58b5dae1ee Handle duplication of reference images for array tool (KICAD-R7M). 2025-07-12 14:07:17 +01:00
Jeff Young 9faf8b3d4c Commenting. 2025-07-05 12:02:36 -06:00
Jeff Young bacc82c589 Debugging. 2025-07-04 16:30:03 -06:00
Jeff Young 97a3a09c90 Embed fonts used in fields as well as text items.
(Also, don't presume a non-stroke font is an outline
font.  We may have more types in the future....)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20578
2025-06-30 18:08:29 -06:00
Jeff Young 9bcf9c643a Don't call TransformShapeToPolygon() with no layer (KICAD-KFR). 2025-06-27 22:59:12 -06:00