See the thread
2.4 Crash (was: Updated LaTeXConfig.lyx (bxjsclasses added))
on lyx-devel (26/01/2023).
The backtrace imply a problem like:
1/ metrics are computed for some info inset
2/ the info inset is regenerated (and thus the paragraph it held is now invalid)
3/ We draw the inset and because of the new (disabled by default)
bookmark display code, we access the id() of the invalid paragraph.
4/ boom!
To fix the issue, introduce a new boolean member that indicates when
the Row object of the metrics should not be used. In this case, the
draw() method returns early.
Typically there are two sources of spacing:
* the button has two pixels added to the left and to the right
* the frame around the text also has 2 pixels to the left and to the right
Note that this value of two pixels is given here for simplicity, but
these are parameterized by methods like textOffset or leftOffset.
What we want to remove is the space after the button and the space
before the frame. This is done in 3 places
In dimensionCollapsed(), the extra space is removed from the dimension
after its computation
In metrics(), the space avoided before the frame is removed from width.
In draw, the whome text inset is drawn with a negative offset.
Fixes#12335.
Error noticed by Coverity:
*** CID 382777: Memory - illegal accesses (RETURN_LOCAL)
/home/lasgoutt/src/lyx/coverity/lyx/src/insets/InsetIndex.cpp: 1866 in _ZNK3lyx15InsetPrintIndex5xhtmlB5cxx11ERNS_9XMLStreamERKNS_12OutputParamsE()
1860
1861 // Collect the index entries in a form we can use them.
1862 vector<IndexEntry> entries;
1863 const docstring & indexType = params().getParamOr("type", from_ascii("idx"));
1864 for (const TocItem& item : *toc) {
1865 const auto* inset = static_cast<const InsetIndex*>(&(item.dit().inset()));
>>> CID 382777: Memory - illegal accesses (RETURN_LOCAL)
>>> Using "indexType", which points to an out-of-scope temporary variable of type "lyx::docstring const".
1866 if (item.isOutput() && inset->params().index == indexType)
1867 entries.emplace_back(IndexEntry{inset, &op});
1868 }
1869
1870 // If all the index entries are in notes or not displayed, get out sooner.
1871 if (entries.empty())
Missing return in `specialCharKindToXMLEntity`. Previously, the
functions that were merged into `specialCharKindToXMLEntity` did not
return any kind of error in case an unknown special character is met
(enumerated value). This behaviour is preserved.
This is a new take on c8e2c17a that was reverted at da67bde61a due to entities no more recognised by the browsers. Corresponding thread on the mailing list: https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg213179.html
This patch is a huge cleanup overall, by removing the distinction between HTML and XML entities (the latter arrived due to the DocBook support).
In InsetListingParams, I also changed the mechanism that relied on " to use an XML entity to be consistent with the rest of the code, mostly in case someone looks for HTML entities and wonders why they are still there.
Also, perform the URL fixing magic for DocBook and XHTML.
As it was, it was impossible to enter e.g. "tel:" type links. Now
choosing the "Other" type just outputs the URL as given.
Also, the addition of "http" or "file" was not being done for
DocBook and XHTML. Now it is.
Instead of having to add and individually test the versions to check
for, we store the current version and test on that with a specific
function isAvailableAtLeastFrom(package, year, month, day)
Currently only used for the LaTeX version, but could also be extended
for package versions.
The previous code explicitly disabled it and this behaviour caused problems (like "A&A" being output as-is, which is wrong in HTML: it should be "A&A").
This is a convenience function for indexing. It adds a copy of the
index inset under cursor after any word in the buffer that is equal
(case-insensitively) to the word preceding the index inset.
The function can be easily used to generate bad indexes (and I warn
about that in the UserGuide), but if used with care, it can also be
extremely convenient.
The new function inset-insert-copy can only be invoked from the ToC.
It is currently only implemented for Index inset.
It is a special lfun because Inset::dispatch is called directly from
the ToC widget with cursor pointing to the inset, whereas the patch
happens in the workarea at caret position. This function cannot be
called directly.
Add an entry for this function in the toc context menu.
Fixes bug #4582.
The change ensures that the function is not seen by the compiler when
the debug mode is not enabled. The flag is not set by default, because
it might have a significant performance impact for large indices.
The reason for the flag is that the default configuration under Linux
forbids the definition of unused functions.