382 Commits

Author SHA1 Message Date
Seth Hillbrand 72ea57d861 Allow local labels without pins if they connect
Local labels on a sheet need to be able to connect just to other labels
for intersheet routing.  This was mistakenly disallowed to check to for
dangling local labels
2026-03-19 14:21:31 -07:00
Seth Hillbrand e541232848 ERC: flag local labels with no local component pin connections
A local label that only connects to other labels or hierarchical sheet
pins without any component pin on the same sheet serves no local purpose
and is likely mislabeled. Extend the existing bus-member check to all
local labels so that ercCheckLabels() flags these cases as
ERCE_LABEL_NOT_CONNECTED.

The allPins > 1 guard prevents double-reporting with
ERCE_LABEL_SINGLE_PIN which already covers the allPins == 1 case.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23346
2026-03-06 11:53:09 -08:00
Seth Hillbrand 37b99c81c6 Fix net absorbing bus in connection graph
When a net subgraph name-matched a bus candidate, the absorption
condition at processSubGraphs only checked that the outer
connection was not a bus. It did not check whether the candidate
was a bus, so a net could absorb a bus subgraph. Later, when
resolving bus parents through the m_absorbed_by chain, the
absorbed-into subgraph had a net driver connection instead of a
bus, triggering the assertion in matchBusMember.

Add a check that the candidate is also not a bus before allowing
absorption. Also replace the assertion in matchBusMember with a
null return as defense in depth, since all callers already handle
null.
2026-03-04 12:32:57 -08:00
Seth Hillbrand 6b8479c967 Fix pin connectivity when junction is at wire midpoint
A junction placed at the midpoint of a wire (without the wire being
split) now correctly connects all wires meeting at that point. The
connection graph previously only connected wires at their endpoints,
so a horizontal wire passing through a junction as a midpoint was not
linked to the vertical wire terminating at the junction.

The fix adds a special case in updateItemConnectivity() that, when
processing a junction item, queries GetBusesAndWires() with
aIgnoreEndpoints=true to find wires whose midpoints coincide with the
junction. These wires are added to the connection map at the junction
position, mirroring the existing label-at-wire-midpoint handling.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23143
2026-03-02 10:54:41 -08:00
Seth Hillbrand 0ec93c024a Fix null deref in GetLibPin() call chains
SCH_PIN::GetLibPin() can return null when a schematic pin has
no backing library pin, but several call sites in the connection
graph and pin code chained GetLibPin()->GetParentSymbol() without
null checks. This caused a SIGSEGV in the ResolveDrivers sort
comparator when opening projects with missing library linkage.

Guard all six call sites so a null GetLibPin() is treated as
"not a power symbol," which is the safe default.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23179
2026-02-20 15:40:31 -08:00
Seth Hillbrand 536bb8e37a Fix crash when jumper pin groups reference non-existent pins
When a jumper pin group contains a pin number that doesn't exist in the
symbol, SCH_SYMBOL::GetPin() returns nullptr. The connection graph code
in updateSymbolConnectivity() pushed these null pointers into a vector
and then dereferenced them in linkPinsInVec()

Skip null pins when building the jumper group connection list. Also add
validation in the symbol properties dialog to reject jumper pin groups
that reference non-existent pin numbers before they can be saved.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23058
2026-02-16 20:15:54 -08:00
Mike Williams 913d38b74b sch connection: prevent double-free on bus members
StoreImplicitConnection accepted a raw SCH_CONNECTION* and
~CONNECTION_SUBGRAPH always deleted everything in
m_bus_element_connections. A double‑free could happen if that same
pointer was also deleted somewhere else. Make the ownership semantics
more clear. Hopefully this fixes / prevents future issues.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/17413
2026-02-04 08:36:55 -05:00
Seth Hillbrand 22428040b7 Fix ERC non-determinism when processing global power pins
Sort m_global_power_pins before processing in generateGlobalPowerPinSubGraphs()
to ensure deterministic iteration order. This prevents the same schematic from
producing different ERC results on consecutive runs.

The sort key uses sheet path, symbol reference, and pin number for a stable
ordering that does not depend on RTree iteration order.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20012
2026-02-02 18:52:35 -08:00
Seth Hillbrand c5840cacdb ERC: Flag bus member labels without local pin connections
When a hierarchical bus connects sheets, local labels that are bus members
may only connect to pins through the hierarchy (in other sheets). Previously,
ERC counted pins from all sheets connected through the hierarchy, which masked
labels that lacked local connections.

Now, for local labels that are bus members, we track local pin count separately.
If a bus member label has no local pin connections, it is flagged as unconnected
even if the net has pins in other sheets through the hierarchical bus.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19646
2026-01-08 09:08:34 -08:00
Seth Hillbrand 511d213462 Handle bus member rename deterministically
Look to see if, in the same bus, the bus member was renamed.  if so,
take the new name unless one of two things:
1) If the current name already matches a different bus member
2) If a different bus updated the neighbor (this preserves the bus name)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18299
2026-01-02 12:14:38 -08:00
Seth Hillbrand f873d672c1 Propogate drivers back
If a higher priority driver renames the bus member, be sure to inform
the rest of the bus

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18119
2026-01-01 19:48:26 -08:00
Seth Hillbrand ba54c640ab Sort bus neighbors
When choosing the shorted net name, ensure that we are alphabetically
sorted for vectors to keep a consistent name

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18606
2025-12-30 15:47:11 -08:00
Seth Hillbrand 61e85f3b25 Don't break out nested buses for implicit connection
Only break out nets

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17771
2025-12-30 12:47:30 -08:00
Jeff Young 36c603b6f0 Resolve text variables when resolving netclasses.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/22413
2025-12-01 17:27:18 +00:00
Seth Hillbrand ae815b88b1 Add Eagle schematic handling for flat schem
Instead of adding small sheets on the root, make top-level sheets
2025-10-23 15:15:37 -07:00
Seth Hillbrand ac8914e46e ADDED: Ability to create flat-type schematics
Allows multiple, top-level schematic sheets.  Records of the sheets are
stored in the project file.  All top-level sheets live under a virtual
root sheet in the hierarchy.  This virtual root is suppressed for export
and general visibility

Fixes https://gitlab.com/kicad/code/kicad/-/issues/2063
2025-10-14 16:07:44 -07:00
Jeff Young 0edae828df Nullptr safety.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/21841
2025-09-29 21:16:08 +01:00
Jeff Young d140261ab1 Formatting. 2025-09-27 13:09:04 +01:00
Seth Hillbrand 47422e19d9 Move Bus Aliases to Project File
Rather than keeping bus aliases in each individual sheet, consolidate
them into a single project file location

Fixes https://gitlab.com/kicad/code/kicad/issues/15450
2025-09-25 18:13:33 -07:00
Seth Hillbrand 6e2b20ed0e Update BS Threadpool to 5.0 2025-09-10 13:02:24 -07:00
Jeff Young 6f59821930 Prefer const &. 2025-08-30 17:45:49 +01:00
Seth Hillbrand c995d47c87 Force overlapping wires to share labels
Crossing wires with pathological label in the center are actually
connected for the netlist.  This is an ERC error but we should keep
things consistent.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21494
2025-08-19 13:19:00 -07:00
Mark Roszko 8d37fc8e80 Fix driver candidates sort not enforcing ordering if two buses have identical members 2025-08-12 20:27:02 -04:00
Mark Roszko 5895c27f4a Rename Prj() on schematic to avoid conflict with global function 2025-08-07 23:21:41 -04:00
Seth Hillbrand 4aa2047f45 Replace alg::delete and alg::delete_if with std c++20 2025-08-04 09:03:16 -07:00
Seth Hillbrand 52f8bf83f6 Remove threading from connection vec update
At most, we will have 4 items.  Or maybe a few more with stacked pins.
But not enough to thread.  The overhead of starting threads and using
mutexes is greater than any savings
2025-08-03 09:18:54 -07:00
Seth Hillbrand b21e3e45d9 Extract generic item connectivity update and add QA 2025-08-03 08:09:01 -07:00
Seth Hillbrand 15ca4b1ba2 Extract symbol connectivity routine and add QA 2025-08-03 08:09:01 -07:00
Seth Hillbrand 7102b2d5e5 Clarify some driver sorting logic and add addl QA 2025-08-03 06:46:28 -07:00
Seth Hillbrand c5545d202d Remove doubly-included kicad_algo 2025-08-02 19:55:55 -07:00
Seth Hillbrand 094870e7a4 String fixes
- Clarify wording in a couple places
- Fix missing 'not' and remove non-standard dashes
- Standardize on single-quote for strings in strings
2025-07-23 17:36:51 -07:00
Seth Hillbrand 3a06de0076 Consolidate ERC label warnings
If global or local labels are floating -> error
If global or local labels are only connected to one pin -> warning

Rather than forcing two different errors depending on whether the label
is local or global
2025-07-18 16:47:25 -07:00
Marek Roszko dea46f7780 Add a TRANSACTION class to experiment with performance metrics in nightlies 2025-06-07 11:43:11 -04:00
Jeff Young e615fcfe90 Improve progress reporting for opening and importing schematics. 2025-06-01 21:05:50 +01:00
Jeff Young 2dd28d18e8 Performance improvements for ERC. 2025-05-26 13:37:57 +01:00
JamesJCode 019921cb48 Add new CONNECTIVITY_CANDIDATE flag
We reuse the CANDIDATE flag in various places across the codebase,
which is probably incorrect given the original intention for the
flag. Clearing it before use would be a performance hit for incremental
connectivity - and we can't rely on other users of the flag to clear
it for us. So we now use a new flag just for connectivity to avoid
other users trampling on connectivity updates.
2025-05-05 22:17:57 +01:00
JamesJCode fabcab1a86 Fix grammar in DRC error message 2025-04-30 00:03:51 +01:00
Wayne Stambaugh 31374906af Fix crash in connection graph when loading a version 8.0 schematic.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20777

(cherry picked from commit c4f9710f98)
2025-04-29 17:17:34 -04:00
Wayne Stambaugh 6dcac5bded Test for hierarchical labels in root sheet when running ERC.
Hierarchical labels in the root sheet cannot be attached to a parent sheet
pin.  By definition they are unconnected.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20810.
2025-04-29 14:21:54 -04:00
Wayne Stambaugh c810ef716d Actually prevent recursion when building connection sub-graph.
Propagating to neighboring connections when not a net will cause an
infinite recursion crash.  Use the wxCHECK2 instead of wxASSERT to
prevent this.

Add a bunch of question comments where the use of wxASSERT is questionable.
2025-04-10 16:31:59 -04:00
Seth Hillbrand bccf365380 Isolate thread pool loops
Now that we are threading things in different frames, we need to watch
that we are not waiting for a process to complete in one frame while
working in another.  To accomplish this, we only wait for our own loop
results

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20572
2025-04-07 12:17:11 -07:00
Mike Williams c67924ccac schematic: convert RunOnChildren to also take recursion mode argument
Prepping for SCH_GROUPS, making consistent with the PCB code.
2025-03-27 13:16:09 -04:00
Wayne Stambaugh 7bc1404956 Fix broken Eeschema QA test when building jumper connectivity.
Don't attempt to access the library symbol jumper pin information when the
symbol doesn't have a valid library symbol reference.
2025-03-25 10:44:30 -04:00
Jon Evans 805ca0c791 ADDED: Jumpers for symbols
Support explicit jumper symbols, defined either by a
flag that all pins with the same number are connected,
or by explicit groups of jumpered pins

Fixes https://gitlab.com/kicad/code/kicad/-/issues/2558
2025-03-24 22:08:46 -04:00
Seth Hillbrand 4f6a73d83c Prevent ERC error with NC pin+NC marker
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20222
2025-03-07 15:24:30 -08:00
Seth Hillbrand 2b557c5497 Revert "Allow a no-connect to connect to a single pin (but not multiple pins)."
This reverts commit ee4a6127c6.
2025-03-07 08:10:04 -08:00
Jeff Young ee4a6127c6 Allow a no-connect to connect to a single pin (but not multiple pins).
Fixes https://gitlab.com/kicad/code/kicad/-/issues/20222
2025-03-06 10:27:11 +00:00
Jon Evans 32b5cf6221 Fix broken build 2025-03-04 21:32:42 -05:00
Seth Hillbrand 49a4699d5a ADDED: Local power symbol option
Local power symbols work like regular power symbols except that they are
scoped only the the sheet in which they are instantiated

Fixes https://gitlab.com/kicad/code/kicad/-/issues/2075
2025-03-04 17:07:46 -08:00
Jeff Young f951497a4f Code brevity. 2025-03-01 21:58:31 +00:00