42 Commits

Author SHA1 Message Date
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
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
Jon Evans a66db54bc5 Cache library manager row lookup 2026-03-03 21:26:09 -05:00
Seth Hillbrand 9b67b0238d Fix thread-safety crash in async library loading
Resolve URI expansion on the main thread before dispatching async
library enumeration tasks. The getUri() call accesses PROJECT text
variables and SETTINGS_MANAGER::Prj() which are not thread-safe.

When a project is unloaded while worker threads are still running,
they would access freed or modified data in PROJECT::TextVarResolver,
causing either an access violation in (KICAD-14DS) or an assertion
failure when the project list is empty (KICAD-11Q9).

Pre-computing the expanded URI on the main thread and passing it to
enumerateLibrary() as a parameter eliminates the data race.

Resolves KICAD-14DS
Resolves KICAD-11Q9
2026-02-15 06:53:22 -08:00
Seth Hillbrand 95b29aba3f Simplify library adapter locking and reduce code duplication
The three library adapters (symbol, footprint, design block) each had
their own AsyncLoad() and GetLibraryStatus() implementations that were
nearly identical. This moves both to the base class.

The per-library mutex is removed. Each adapter now uses a single
shared_mutex for its library map. Read operations take shared locks,
write operations take unique locks. This simplifies the locking model
from two levels to one.

Derived classes override a new enumerateLibrary() method to perform
type-specific enumeration. The base class handles threading, status
tracking, and error handling.

Also adds a new WithFootprintsForLibrary() routine that takes a callback
but handles the locking internally so callers don't need to remember
2026-01-23 08:44:31 -08:00
Jeff Young 9bc7c1d63e Improve status update strategy for nested tables. 2026-01-22 13:32:27 +00:00
Jeff Young f4e025596b Passing a string to LIBRARY_TABLE's c'tor doesn't do what you think it does.
Also fixes nested tables being deleted out from under
the dialog.

Also fixes a bug where PANEL_DESIGN_BLOCK_LIB_TABLE
had fallen behind the the other two.
2026-01-20 13:18:46 +00:00
Seth Hillbrand 5e2d8b9a98 Abort async library loads before modifying project list
When starting pcbnew in standalone mode and quickly opening a file, a race
condition could occur where background library loading threads tried to access
Prj() while the project list was being modified. This caused an assertion
failure: "no project in list".

The fix aborts any async library loads before modifying m_projects_list in
SETTINGS_MANAGER::LoadProject() and UnloadProject(). This ensures background
threads have completed before the project list becomes temporarily invalid.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22697
2026-01-13 11:11:54 -08:00
Sven Pauli 3bf9396c28 Fix crash when starting FP editor during library load 2026-01-12 09:55:34 -08:00
Seth Hillbrand 9b9899979b Stop showing popup for library load errors
Errors are stored to a vector for display after clicking the warning
icon in the toolbar.
2025-12-31 13:15:06 -08:00
Jon Evans a900631993 Library tables: support various orders of tokens
Fixes https://gitlab.com/kicad/code/kicad/-/issues/22581
2025-12-27 17:58:27 -05:00
Jeff Young 29eebadbfd Reprocess library tables when they change. 2025-12-08 13:01:22 +00:00
Jon Evans f59ae6d6f6 Clean up management of library adapters 2025-12-07 11:58:57 -05:00
Seth Hillbrand 2d538d3d69 ADDED: Remote symbol placement
Allows activating a display panel that shows a webpage designed to
provide instances of symbols, footprints, 3d models and spice models to
the designer.

The webpage can be installed via PCM or directly in the panel.  Webpages
should be registered with the KiCad project in order to avoid a warning
when showing content.
2025-11-29 17:58:32 -08:00
Jon Evans 253f965a18 Improve design block error reporting 2025-11-27 16:23:34 -05:00
Jeff Young 8f8f05a944 Improve error reporting for lib table rows. 2025-11-23 22:36:37 +00:00
Jeff Young c1610f2983 Push a bunch of symbol library editing code down into shared classes. 2025-11-06 14:10:45 +00:00
Jon Evans c7c23c2180 Remove legacy library table code 2025-11-04 06:54:53 -05:00
Jon Evans baa29c1a58 Port footprint library table to new system 2025-11-04 06:54:53 -05:00
Jon Evans c69cf6487e Push library table saving to LIBRARY_TABLE 2025-10-21 21:48:46 -04:00
JamesJCode 3d768498b7 Synchronise access to LIBRARY_MANAGER::m_adapters 2025-10-18 22:14:16 +01:00
Jeff Young d5e9169b76 Coverity fixes. 2025-10-17 17:02:14 +01:00
Jon Evans 2f99045186 MSVC build fixes 2025-10-15 22:18:55 -04:00
Jon Evans 2d24edf84f Re-enable library configuration dialog 2025-10-15 22:18:55 -04:00
Jon Evans 6e9811fd07 Support resetting symbol library table 2025-10-15 22:18:55 -04:00
Jon Evans d85fb038ba Port design blocks to new library table system
Generalize library adapter code to be shared
2025-10-15 22:18:54 -04:00
Jon Evans 93b59f011a Generate default library tables from first-start wizard 2025-10-15 22:18:53 -04:00
Jon Evans c49c400f79 Don't treat empty lib table file as valid 2025-10-15 22:18:53 -04:00
Jon Evans 266c8c8754 Refactor and consolidate startup wizard
- Add welcome page
- Add settings migration
- Add library table configuration
- Combine sentry and updates into a privacy step
- Support in single-top mode
2025-10-15 22:18:52 -04:00
Jon Evans 25f3fd1b6a Port importers to new library system 2025-10-15 22:18:52 -04:00
Jon Evans d0cbc983be Add support for PCM libraries to library manager 2025-10-15 22:18:51 -04:00
Jon Evans 992be7fe35 Move symbol editor to new library system 2025-10-15 22:18:51 -04:00
Jon Evans 76aaff97a5 Patch up recently-added MAIL_ADD_LOCAL_LIB 2025-10-15 22:18:51 -04:00
Jon Evans 940acd18d8 Move new row creation to LIBRARY_TABLE 2025-10-15 22:18:51 -04:00
Jon Evans edad0c2af1 Move library table editing dialog to new system 2025-10-15 22:18:50 -04:00
Jon Evans 73dd8146fa Add output formatter to LIBRARY_TABLE 2025-10-15 22:18:50 -04:00
Jon Evans 194091acae Switch schematic editor to using new library system
ADDED: lazy loading of symbol libraries in chooser
2025-10-15 22:18:50 -04:00
Jon Evans f9bee87185 Handle disabled and hidden attributes 2025-10-15 22:18:50 -04:00
Jon Evans 6baf5e798e Reduce use of pointers for properties maps 2025-10-15 22:18:50 -04:00
Jon Evans 0b2b6b2e77 Move database and HTTP libs over to new adapter model 2025-10-15 22:18:49 -04:00
Jon Evans 0752b43057 Create a new library manager responsible for table loading 2025-10-15 22:18:49 -04:00
Jon Evans a75632d4d6 Create a new library table parser and base class 2025-10-15 22:18:49 -04:00