11895 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
Seth Hillbrand d342761fa0 Fix one more use after free vector 2026-03-19 13:28:34 -07:00
Damjan Prerad 4149bee32b Local history: reuse existing dialog strings 2026-03-19 20:45:45 +01:00
Alex Shvartzkop 182f99abcb Fix MSW build error. 2026-03-19 21:48:45 +03:00
Damjan Prerad d23c34aff3 Local history: fix Win64 enum macro collision 2026-03-19 17:57:53 +01: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
Alex Shvartzkop 969dbe196f Don't translate strings that shouldn't be translated. 2026-03-19 18:46:37 +03: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
Seth Hillbrand 65fdc4ea00 One more swing at Wayne's webview crash
The teardown order between C++ DTOR and wx may get mis-aligned, so don't
try stopping the timer if it might already be freed
2026-03-18 17:21:36 -07:00
Damjan Prerad 246a1344a9 DRC Rule Editor: make graphics consistent and use proper colors 2026-03-18 22:34:26 +01:00
Seth Hillbrand 5f6877002f webview: guard against destroyed browser in deferred init
The wxWebView child can be destroyed before the
WEBVIEW_PANEL when WebKit's GTK widget is torn down
asynchronously (e.g., WebKit process crash or init
failure). The retry timer keeps firing on the
still-alive panel but m_browser is now a dangling
pointer, causing SIGSEGV at the virtual dispatch in
AddScriptMessageHandler.

Bind wxEVT_DESTROY on the wxWebView to null out
m_browser and stop the timer when the browser is
destroyed. Add null guards in DoInitHandlers,
AddMessageHandler, and ClearMessageHandlers.
2026-03-18 13:52:03 -07:00
Seth Hillbrand e25cb1354d webview: defer handler init when main loop is mid-yield
AddScriptMessageHandler internally calls RunScript, which
yields the event loop. When this fires from a timer during
a wxProgressDialog yield (e.g., schematic loading checkpoint),
the reentrant yield crashes WebKit's JSC in sanitizeStackForVM.

The existing guard only checked for non-main event loops but
missed the case where the main loop itself is yielding. Add
IsYielding() to both DoInitHandlers and AddMessageHandler guards
so the timer re-defers until the loop is idle.
2026-03-18 13:26:58 -07:00
Seth Hillbrand 20908ce39b kicad: fix crash on project close in webview
Replace CallAfter with m_initRetryTimer.StartOnce(0)
which gives the same deferred execution but is
automatically cancelled by ~wxTimer when the panel
is destroyed.
2026-03-18 13:22:42 -07:00
Damjan Prerad dc277bf26a DRC Rule Editor: make graphics consistent and use proper colors 2026-03-18 20:41:35 +01:00
Seth Hillbrand 36f0da1556 eeschema: abort async loads before destroying library tables
Background async library loading workers hold raw LIBRARY_TABLE_ROW
pointers into the LIBRARY_TABLE::m_rows vector. When ProjectChanged()
calls LoadProjectTables(), it destroys the old LIBRARY_TABLE objects
via unique_ptr replacement.

The workers were not aborted until after the tables were destroyed,
creating a window where workers could access freed memory.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23480
2026-03-18 12:18:23 -07:00
Mike Williams 08349b8d8a design blocks: don't crash on missing preview widget
Copied from footprint preview widget, which has the same issue
2026-03-18 10:12:43 -04: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 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
Jeff Young 9ecc6fe838 Numeric evaluator only supports 8-bit chars.
(Worse, wxWidgets' auto-converter can crash on certain input.)
2026-03-16 19:06:08 +00:00
Seth Hillbrand 6ed8fa0fae Fix crash when realizing instance of OpenGL
The FOOTPRINT_PREVIEW_PANEL may instantiate prior to any other checks,
we need to ensure that this widget is realized on Linux prior to getting
the OpenGL calls otherwise GTKGetDrawingWindow may return NULL
incorrectly
2026-03-16 10:46:08 -07:00
Seth Hillbrand 37ef308ef3 Avoid calling OpenGL if we fail init
If we can't initialized OpenGL, then glFlush will be null, so calling is
a guaranteed crash
2026-03-16 08:37:33 -07:00
Jon Evans 1637a124ff API: always serialize with UTF-8 2026-03-15 22:02:55 -04: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 1ef76f798d Cap background library loading threads
AsyncLoad() previously submitted one thread pool task per
library, which could saturate all available cores during
startup. This starved the GUI and blocked other thread pool
work like DRC.

Restructure to use a work-stealing pattern where a limited
number of worker tasks each pull from a shared queue. The
worker count is capped at pool_size - 2 (minimum 1), leaving
threads free for the UI and other operations. Tasks are still
submitted at lowest priority so any higher-priority work
takes precedence in the queue.
2026-03-12 13:07:46 -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 f3441c00a3 Import Altium project variants
Parse variant data from Altium .PrjPcb project files and
apply it to both schematic symbols and board footprints
during import. Each ProjectVariant section is read as an
INI group, and per-component variation entries are mapped
to KiCad variant structures on the matching designators.
2026-03-12 09:33:59 -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 eb62257333 Update contributor lists 2026-03-11 15:36:33 -07:00
Seth Hillbrand 001c196e7f UrlEncode: percent-encode UTF-8 bytes, not Unicode code points
RFC 3986 requires percent-encoding individual UTF-8 bytes.  The
previous implementation iterated wxUniChar code points, producing
incorrect output for non-ASCII characters (e.g. é became %E9 instead
of %C3%A9, and multi-byte characters like emoji produced invalid
percent-encoding with more than two hex digits).
2026-03-11 13:42:54 -07:00
Wayne Stambaugh 1b9f7eef51 Fix Linux build errors. 2026-03-11 15:27:29 -04:00
Seth Hillbrand be2c612dc3 DRC rule editor: fix Windows paint artifacts
The bitmap overlay panels never cleared their background before
drawing. With wxBG_STYLE_PAINT the system skips auto-erase, so
stale pixels from previous panels bled through on Windows during
scrolling and rule switching.

Switch OnPaint from wxPaintDC to wxAutoBufferedPaintDC and clear
the full client area before drawing the bitmap. Wrap the panel
swap in SetContentPanel with Freeze/Thaw to suppress intermediate
repaints between destroy and layout.

Widen overlay text fields on Windows by 15px via a new platform
constant DRC_RE_OVERLAY_WE to allow for Windows wxTextCtrl border
padding
2026-03-11 12:12:12 -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
Seth Hillbrand 42928c8b2f Fix Move command grabbing from grid point instead of anchor
The Move command grabbed footprints from the nearest grid point rather
than the footprint anchor. This was caused by the reference point being
grid-aligned at drag start (commit 89be3fd390), which was a workaround
for fractional-nanometer positioning errors with non-page display origin.

Fix the root cause instead: AlignGrid(VECTOR2I, VECTOR2D, VECTOR2D)
relied on implicit VECTOR2D->VECTOR2I truncation to pass grid parameters
to computeNearest. For grid sizes that aren't exact in IEEE 754 double
(e.g., 0.254mm = 10 mil becomes 253999.999... instead of 254000), the
truncation produces incorrect grid sizes. Use KiROUND for the conversion
so all grid operations produce exact grid multiples.

With AlignGrid returning correct positions, the move tool no longer needs
to grid-align its reference point. Restore the anchor-based grab and the
GetMoveWarpsCursor() preference that 89be3fd390 removed.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23308
2026-03-10 11:07:39 -07: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
Seth Hillbrand a5445df107 Cycle through options on single-click for non-tool flyout groups
Setting flyout groups (units, crosshair, line modes) now cycle to the
next option on single-click instead of requiring a long-press to open
the palette. Tool flyout groups (route track, tune, dimensions, origins)
continue to activate the displayed tool on click.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23349
2026-03-09 15:06:25 -07:00
Ian McInerney 783480d2a6 Always force toolbars to be visible when restoring settings
There seem to be some cases where the AUI perspectives are getting saved
with false visibility. This means they aren't getting shown when
settings are restored. We don't support hiding toolbars, so just always
force them to be shown because otherwise there is no other way to get
them back.
2026-03-08 23:22:32 +00:00
John Beard d5e129a3a0 Pcbnew/Allegro: Break out zone merge function.
This is a tricky function that really needs a test around it.

Also it has several assumptions and traps:

 - It will not work if the zones have multiple polygons in the poly sets
 - It will not work if any polygon has line chains in a different order
 - It is quadratic in number of zones and the compare itself is
   superlinear (Simplify is called, evilly in a const function, which is
   quadratic) and in a cyclic comparison, sort, which is presumably nlog-n
   ish.

However, at least for the quadratic nature, profiling shows this to be
absolutely insignificant even for the VCU118 board.
2026-03-08 22:17:43 +08:00
Jon Evans 6098e745be Fix crash in AutoDecodeCSV when nothing is found in the input 2026-03-08 10:10:11 -04:00
Jon Evans c62b9aad23 API: Avoid redundant serialization of polyline arcs
Fixes https://gitlab.com/kicad/code/kicad-python/-/issues/79

(cherry picked from commit 0aeb33f94f)
2026-03-08 00:22:23 -05:00
Jeff Young 4da7c180c2 Apply KiCad look & feel to DRC Rules Editor. 2026-03-07 19:28:46 +00:00
Seth Hillbrand 17d53bd77f Cycle through options on single-click for toggle flyout groups
When clicking flyout buttons for non-tool groups (crosshair style,
units, line modes), advance to the next option in the group instead
of re-dispatching the already-active action. Tool-type flyout groups
retain existing behavior of selecting the displayed tool.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23349
2026-03-06 11:28:28 -08: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
Wayne Stambaugh 594b982cd9 Fix Linux build error. 2026-03-05 15:54:39 -05:00