GuessPluginTypeFromLibPath() was previously testing the type, but also the
existence of the lib file of *.kicad_sym filename, but when creating a new lib,
its existence obviously must not be tested
Recommendation is to avoid using the year nomenclature as this
information is already encoded in the git repo. Avoids needing to
repeatly update.
Also updates AUTHORS.txt from current repo with contributor names
GetLibrary is allowed to return null, so we need to check before
dereferencing
Fixes https://gitlab.com/kicad/code/kicad/-/issues/19236
(cherry picked from commit 5552d63f7076ec417922eb2fdf933f8cd74ff93f)
It doesn't even use the forward-declared
SYMBOL_LIB_TABLE.
Including this pulls in the whole richio system,
and sch_symbol.h is a very-included header.
Quite a few things do use SYMBOL_LIB_TABLE, but nowhere
near as many as use SYMBOL.
This function just uses the buffer, it doesn't retain
part-ownership, so it doesn't need to get a copy of the
shared_ptr (or even know that the shared_ptr exists).
A reference count of the buffers is safely held by the caller
in SaveLibrary while this function executes.
SYMBOL_BUFFER GetSymbol and GetOriginal cannot return null,
as the SYMBOL_BUFFER class internally ensures that the
original and current symbol pointers are always filled
through checks in the ctor and setters.
This means that clients don't need to null-check the returns,
which is good because they mostly already do not.
Return references instead, to formalise the non-nullity of
these pointers and absolve the calling code of having to
consider if they might be null.
Previously, SYMBOL_BUFFER took plain pointers and took ownership
of it (plus the ownership of an internal new'd pointer).
Use unique_ptr to express this relationship more clearly and
safely.
Add a non-null assert in SYMBOL_BUFFER's ctor.
Use more restricted-scope variables in a couple of places where
a re-used variable was not required.
There are still memory-leak opportunities in here, for example
SaveBuffer new's things and can return without handing them over
or deleting.
Again, this doesn't retain part-ownership of the pointer
and null is a wxCHECK failure. So hoist the null check
and then handle it as a ref (=non null, caller owns).
Also fixes a trivial mem leak in test_symbol_library_manager.cpp.
DeleteBuffer took a std::shared_ptr by value. This means
it claims to take (and keep) part-ownership of the pointed-to
item. However, this function does not take any ownership or
change the item, it just refers to it. It also does not null-check
the pointer. So it should be a const reference to the item.
Ownership semantics are then: the caller retains ownership
while the function executes.
(It also saves a shared_ptr ref count, but that won't be
important here).
If you use save as into a different library and change the symbol name
while overwriting an existing symbol, the libid didn't get updated,
leading to an error message when trying to load the newly saved symbol.
The IO_RELEASER is a thin-wrapper around a std::unique_ptr, but done
this way to allow easier addition of a custom deleter in the future if
something needs to call back into the IO_MGR.
* Fix issue handling symbols with multiple inheritance.
* Remove unused code from the symbol library manager object.
* Splits out the library buffer and symbol buffer object so the can be unit
tested without having to mock the symbol library manager object.
* Add unit tests for library buffer and symbol buffer objects.
- Move PLUGIN_FILE_DESC to common.
- SCH_PLUGIN: rename Load -> LoadSchematicFile, Save -> SaveSchematicFile.
- Use PLUGIN_FILE_DESC and CanRead* in schematic plugins.
- Return none/unknown types from Find/GuessPluginType functions.
- Iterate over file types for file wildcards.
- Clean-up header checking in IO plugins.
- Use PCB plugin list in IO_MGR::GuessPluginTypeFromLibPath.
When editing or viewing library symbols, the files are watched for
underlying changes. If any occur, the user is either prompted to reload
(if reloading would overwrite their current edits) or the file is
silently updated to the current version on disk.
This also sets a custom assertion handler to avoid unneeded crashes when
recieving invalid SAMBA packets and turns off assertions entirely when
running in release (non-debug) mode