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().
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
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
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.
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
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.