7667 Commits

Author SHA1 Message Date
Jon Evans 067533928b Reduce memory usage of EDA_SHAPE pt 2 2026-03-19 21:32:06 -04:00
Jon Evans 5353982a4a Reduce memory usage of EDA_SHAPE 2026-03-19 21:32:02 -04:00
Jon Evans 082ec945fc Reduce memory usage of text/fields
Lazy construction of caches that are only needed
for some of these reduces their footprint significantly.
2026-03-19 21:25:34 -04:00
Damjan Prerad b80ee13595 Local history: add restore dialog
The old restore dialog only showed a simple list of snapshots
so it was hard to see what each entry contained before
restoring. It also had a bug where pressing Restore could
close the dialog but not restore anything, because the
pre-restore backup step treated no changes to save as a faliure.

This change adds a dedicated restore dialog that shows the
snapshot time, summary, hash, and changed files. It also
updates the restore code to load snapshot details for the
dialog and to continue with the restore when the backup
step finds no new changes.
2026-03-19 17:04:02 +01:00
Damjan Prerad 1aa2d1494e DRC Rule Editor: add courtyard clearance bitmap 2026-03-19 17:04:02 +01:00
Seth Hillbrand 9fbb0378c5 Move webview pointer to wxweakref
Uses wx reference counting infrastructure to ensure we have a valid
pointer and adds proper null checking for the webview not being
instantiated yet
2026-03-18 18:00:57 -07:00
Damjan Prerad 8b2cb94cb1 pcbnew: fix Flip Board View from custom toolbars
Flip Board View did not work correctly when it was added to a
custom toolbar. The board flip worked from the view menu or
appearance panel.

This change stores the board flip state in PCB_DISPLAY_OPTIONS
and applies it through SetDisplayOptions(), the same way other
display toggles are handled. The toolbar, menu, and appearance
panel now use the same state, so Flip Board View works correctly
from custom toolbars.
2026-03-18 12:41:51 +01:00
Bernhard Kirchen e3f049f4d9 ADDED: expand VARIANT and VARIANT_DESC in drawing sheets
* add VARIANT and VARIANT_DESC to the list of known vars in the drawing
  sheet editor.
* cache variant and variant description in respective objects.
* expand the respective text variables when building the drawing sheet.
* keep the cached variant and its description up-to-date when selecting
  a variant in the GUI.
* pass variant and its description to the plotters.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23430
2026-03-17 15:39:34 +00:00
Jeff Young a9f1b41dc2 Attempt to fix non-Mac includes. 2026-03-17 14:41:36 +00:00
Jeff Young 71b48eabd7 Allow compiler to enforce char vs wxUniChar. 2026-03-17 14:25:32 +00:00
Jeff Young dbc5e021ed Repair hatching knockouts post-optimization.
The knockout algo was a post-processing step, but it
only knew about the poly representation, and not the
new line segment optimization.  Since the post-process
step proved to be fragile, knockouts are now fetched
from a callback from EDA_SHAPE::UpdateHatching().
2026-03-17 13:16:06 +00:00
Jeff Young e4b8fde25b PANEL_PREVIEW_3D_MODEL does its own pretty-printing.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/23401
2026-03-17 13:16:06 +00:00
Seth Hillbrand 902048a172 Move history autosave Prettify, file I/O, and git ops to background thread
Savers now serialize to in-memory HISTORY_FILE_DATA on the UI thread,
then Prettify + file writes + git stage/diff/commit run on a background
thread via GetKiCadThreadPool(). An atomic skip-if-busy flag prevents
overlapping saves; WaitForPendingSave() ensures clean shutdown.

Extracted FormatBoardToFormatter and FormatSchematicToFormatter so
SaveToHistory can serialize without touching disk. PROJECT savers use
sourcePath for file-copy semantics since project files are small.
2026-03-16 12:16:45 -07:00
Damjan Prerad e25c5a9848 Fix Symbol Editor crash from stale search-term span
Fixes https://gitlab.com/kicad/code/kicad/-/work_items/23429
2026-03-13 21:07:56 +01:00
Seth Hillbrand c2749d3b49 Fix WebView freeze during modal dialogs
WebKit's AddScriptMessageHandler calls RunScript internally,
which yields the event loop via DoYieldFor. When this runs
inside a nested event loop (e.g., Update PCB from Schematic's
modal dialog), JSC crashes in sanitizeStackForVM.

The previous fix used CallAfter to defer handler registration,
but CallAfter events fire immediately in the modal dialog's
event loop, creating a tight busy-wait that freezes the UI.

Replace CallAfter re-deferral with a wxTimer that retries
every 200ms until the main event loop is active. Also guard
AddMessageHandler's late-registration path with the same
nested loop check so handlers added after init are safe too.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23423
2026-03-13 11:01:45 -07:00
Seth Hillbrand 265b00d994 Try to fix DRC rule editor slow load on Windows
During LoadExistingRules, each call to AppendNewRuleTreeItem
triggered SelectItem, which fired the selection-changed handler.
That handler created a full PANEL_DRC_RULE_EDITOR per rule,
compiling 14 regex patterns, instantiating Scintilla, running
layout, then immediately destroying it when the next rule was
appended.  Also fix other potential slow downs
2026-03-12 09:56:49 -07:00
Seth Hillbrand 5c59527278 Add 6 missing languages to LanguagesList[]
Add Estonian, Farsi, Hindi, Croatian, Georgian, and
Telugu
2026-03-11 15:58:02 -07:00
Seth Hillbrand 2dbba4a60a Remote Symbol: consolidate, update and harden
Extract duplicated helpers from remote provider files into shared
utilities.  Split sendRpcMessage into purpose-specific functions.
Implement standard nonce-based exchange for re-auth.  Provide
additional models for more efficient model/symbol/fp/etc using
external URLs.  This allows us to better handle connection errors,
retries and large data packets.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23381
2026-03-11 06:41:44 -07:00
John Beard 8aaea1fc94 Settings manager: explain the assert 2026-03-10 22:32:20 +08:00
John Beard 6cd04bde02 Allegro: multithread zone fill handler for 70% loading speedup (VCU118)
Intersecting and fracturing zone fills takes forever for complex
fills (VCU118 has some fills severa with hundreds of thousands of
points).

However, they are trivially parallelisable - so do that and cut VCU
board load times by 70% - YMMV depending on CPU.

Further save 10% by sorting the heaviest zones first which is nice,
but the real thing to avoid is accidentally scheduling the biggest
zones consecutively on the same thread, which could be a substantial
penalty.

This has the happy effect of reducing the Allegro test suite to under
a minute (VCU118 dominates)
2026-03-10 22:32:20 +08:00
Jon Evans 270a6830b0 Fix a few issues with library start wizard
- Improve text layout / responsiveness
- Fix missing stock tables warning not showing up in the right cases

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22923
2026-03-10 08:48:04 -04:00
Jon Evans 10592c242d Fix status bar progress layout issues
Alignment and padding were off, and layout was
not getting done properly on draw frames until
the window was resized.
2026-03-09 23:55:35 -04:00
Jeff Young 4da7c180c2 Apply KiCad look & feel to DRC Rules Editor. 2026-03-07 19:28:46 +00:00
Seth Hillbrand 1cf4284930 IPC-2581: use schematic revision for BOM
The BOM revision in IPC-2581 export was hardcoded to "1.0"
instead of reflecting the actual design revision.

The project file stores two separate fields: bomRev for
explicit user overrides set in the PCBnew export dialog or
via --bom-rev on the CLI, and schRevision for the value
auto-propagated from eeschema.
2026-03-06 09:13:56 -08:00
Seth Hillbrand 1eb3f5f3eb Recover OpenGL after sleep/wake context loss
When the GPU context is invalidated by sleep/wake or a driver
reset, glMapBuffer fails with GL_OUT_OF_MEMORY and the renderer
permanently falls back to Cairo. Instead, attempt a full OpenGL
GAL reinit once before giving up. SwitchBackend recreates all
GPU resources and SetGAL triggers clearGroupCache so every
cached item is regenerated on the next frame. A flag prevents
infinite retry loops and resets after each successful paint.
2026-03-05 08:25:31 -08:00
Damjan Prerad 700df8720d DRC Rule Editor: Fix soldermask 'silver' typo to 'sliver' in DRC Rule Editor 2026-03-05 14:30:48 +01:00
Seth Hillbrand 9c6f99e0dd Fix import lockup on non-PCB files
LAYER_RANGE enters an infinite loop when constructed with
layer_count < 2. The next_layer() arithmetic underflows,
producing unreachable termination values, so the iterator
increments forever. This happens during board import when a
file produces a board with zero copper layers.

Clamp layer_count to a minimum of 2 in the LAYER_RANGE
constructor since F_Cu and B_Cu are always present.

Add content validation to the Fabmaster plugin, which
previously accepted any .txt file based on extension alone.
CanReadBoard now scans for !-delimited rows containing
known Fabmaster column headers before claiming the file.
2026-03-04 17:37:03 -08:00
Seth Hillbrand e60e619655 Fix data race in library manager row cache
Background library loading threads call GetRow() through
loadFromScope(), which writes to m_rowCache concurrently
with the main thread clearing it in loadTables(). The
unsynchronized access corrupts the map's red-black tree,
causing a double-free crash when switching projects.

Add m_rowCacheMutex to protect all m_rowCache accesses.
Also replace std::tie with std::make_tuple to avoid
unnecessary temporary conversions, and use a single
find() instead of contains() followed by at().
2026-03-04 12:32:57 -08:00
Seth Hillbrand 02f31c8de1 Fix empty symbol chooser previews on first load
Add an aAllowSkip parameter to DoRePaint that gates both skip
checks.  onPaint and ForceRefresh pass false so they always
execute the full GL/Cairo cycle.  The rate-limited Refresh path
continues to pass true (the default), preserving the GPU
utilization improvement from b728c08b7a.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23325
2026-03-04 08:11:02 -08:00
John Beard 6c5b1bbc8b Pcbnew: Allow to skip layer mapping using advanced config
Clicking Automap/OK was fun for a bit.
2026-03-04 23:28:31 +08:00
Jon Evans aa21aacd72 Improve efficiency of power symbol filtering
Calling GetLibSymbol for every node is quite expensive,
put this info into the node directly instead.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23267
2026-03-03 21:26:09 -05:00
Jon Evans a66db54bc5 Cache library manager row lookup 2026-03-03 21:26:09 -05: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
Seth Hillbrand b404b30fb9 Fix integer overflow in THROTTLE first call
Initializing m_last to time_point::min() causes signed integer
overflow when computing now - m_last, since the nanosecond
difference exceeds int64_t range. Initialize to now - interval
instead so the first Ready() call passes naturally.
2026-03-03 12:30:32 -08:00
Seth Hillbrand 18c025f21f Skip redundant VIEW updates and repaints
Add m_hasPendingItemUpdates to VIEW so UpdateItems() can
return immediately when no item has queued update flags.
The flag is set wherever m_requiredUpdate is modified and
cleared at the end of UpdateItems().

In DoRePaint(), check the new flag alongside IsDirty() and
cursor movement to skip both item processing and the GL
draw cycle when nothing has changed. Route onPaint through
Refresh() so the existing frame-rate throttle applies to
native paint events as well.
2026-03-03 11:33:10 -08:00
Seth Hillbrand fff428dcd6 Add THROTTLE class and DrainPendingEvents
Five call sites independently reimplemented the same
time-gated throttle pattern.  This consolidates them all
into a single THROTTLE class backed by steady_clock.

Three call sites duplicated the wxWidgets YieldFor workaround
for timer-event backlog (wxWidgets issue #26192). This replaces them
with a shared DrainPendingEvents free function.
2026-03-03 11:33:10 -08:00
Seth Hillbrand 2c4368be85 Fix crash opening footprint chooser after project switch
PG_FPID_EDITOR is registered in wxPropertyGrid's global editor
registry and persists across SCH_PROPERTIES_PANEL lifetimes.
UpdateFrame() didn't update the netlist callback lambda.

To fix this, we add an UpdateCallback() to PG_FPID_EDITOR and
call it alongside UpdateFrame() when reusing an existing
editor instance.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23307
2026-03-02 11:50:30 -08:00
Seth Hillbrand 314429373c pcbnew: Update zone manager
Update zone manager to improve usability. Filter zones based on layers,
provide move to top/move to bottom actions, global arrow key navigation,
zoom preservation across zone switches, right-click zoom-to-fit on the
preview canvas, and pixel-aligned icons for top/bottom move buttons.
2026-03-01 22:07:19 -08:00
Damjan Prerad c753d6cd34 DRC Rule Editor: Add skew field to matched length diff pair constr.
The matched length diff pair panel had skew data in the constraint class
but no UI field to display or edit it. Added a dedicated overlay panel
with min/opt/max length plus max skew fields, a new bitmap showing a
diff pair with length arrows and skew indicator.
2026-03-01 12:14:16 +01:00
Alex Shvartzkop 21db4a0238 Avoid sorting layers after setting each layer rendering order in VIEW.
Saves 100 ms when opening Choose Symbol dialog.
2026-02-28 13:47:03 +03:00
Seth Hillbrand 1e2a2fb02c Fix minor safety and visibility issues
Move onUpdateUI from public to private in EDA_BASE_FRAME since
it is an internal event handler bound via Bind(), not part of
the public API.

Capture the empty-check result before erasing rows in
library_manager.cpp to avoid using invalidated iterators from
the subrange returned by std::ranges::remove_if.

Add null guards to the netHighlightCond toolbar condition
lambda in PCB_EDIT_FRAME to prevent null dereference during
shutdown, matching the pattern used by other toolbar
conditions fixed in f962de966b.
2026-02-27 19:13:47 -08:00
Seth Hillbrand fbe31e5d36 Consolidate wxEVT_UPDATE_UI handlers to a single dispatcher
SearchDynamicEventTable does a linear scan through all dynamic
Bind entries for every dispatched event, regardless of event type.

Replace the per-action Bind() calls with a single wxID_ANY handler
that dispatches to the existing m_uiUpdateMap through a hash map.
This reduces the per-event scan from around 150 to about 1 for all
event types.  This is particularly noticeable during high frequency
events like mouse drag.
2026-02-27 15:21:23 -08:00
Damjan Prerad e2a9f06420 Fix uninitialized m_isNew causing asterisk on all DRC Rule Editor tree items
The default constructor of RULE_EDITOR_DATA_BASE left m_isNew
uninitialized. On Linux, the garbage memory value was assigned
causing IsNew() to return true for every rule and appending
astersix to all tree items.

Fix by adding a default member initializer: m_isNew = false.
2026-02-26 11:34:41 +01:00
Damjan Prerad cf80df280c Fix ghost windows appearing in macOS Mission Control when using DRC Rule Editor
Clicking on rules in the tree created a wxDragImage each time, which on
macOS opens a hidden full-screen window. These windows were never cleaned
up and piled up as ghost windows in Mission Control.

Removed wxDragImage and replaced drag feedback with a highlight
on the drop target item.
2026-02-26 00:13:34 +01:00
Alex Shvartzkop 4889204ec5 Include glad before glcanvas. 2026-02-26 00:08:47 +03:00
Seth Hillbrand f826061434 Move DRC Rule Editor out from behind AC 2026-02-24 16:32:02 -08:00
Seth Hillbrand 930dc9933c Update bitmaps 2026-02-24 10:28:11 -08:00
Damjan Prerad ea06a64cdd DRC Rule Editor: Remove duplicate hole-to-hole clearance constraint
Remove HOLE_TO_HOLE_CLEARANCE from the rule editor as it generates the same
DRC rule as HOLE_TO_HOLE_DISTANCE.
2026-02-24 17:26:37 +01:00
Ian McInerney 2c4a4cd8f0 Fix the font selector "Leave Unchanged" option in global edit dialogs
Fixes https://gitlab.com/kicad/code/kicad/-/issues/23190
2026-02-24 15:56:50 +00:00
Seth Hillbrand 08bb3601bd Increase LINE_READER max line length to 16 MB
The previous 1 MB limit caused "Maximum line length exceeded" errors
when loading schematics containing large embedded images or other long
quoted tokens.  The S-expression parser (DSNLEXER) requires entire
quoted strings to fit within a single line buffer, so Prettify cannot
split them across lines.  Raise the limit from 1 MB to 16 MB and add
regression tests.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23162
2026-02-24 07:55:24 -08:00