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.
This commit had had an additional not documented change: redraws
happen only when they are needed. This did not help fix the bug, but
looked smart on first sight. Alas, I find that these smart changes
added because "why not?" tend to come back to haunt me eventually.
In particular this case, the problem was that the code tested whether
the offset of anchor paragraph had changed, but not whether the
paragraph itself had changed. This means that, when switching from one
section to another with the outliner, the view was not updated.
Fix the following warning:
src/frontends/qt/GuiDocument.h:377:7: error: 'eventFilter' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
bool eventFilter(QObject * sender, QEvent * event);
^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qobject.h:139:18: note: overridden virtual function is here
virtual bool eventFilter(QObject *watched, QEvent *event);
^
Amends 62413580de.
If `havetable == true`, a lot of the code didn't make any sense: in particular, it was outputting a level of <m:mrow> too many.
Also, add some comments and rewrite the comment about mlabeledtr.
Contributed by lynx: https://www.lyx.org/trac/ticket/12629
This was:
../../master/src/mathed/InsetMathBox.cpp:116:20: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<wchar_t> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
116 | for (int i = 0; i < parts.size(); i += 2) {
| ~~^~~~~~~~~~~~~~
../../master/src/mathed/InsetMathBox.cpp:120:20: warning: comparison of integer expressions of different signedness: ‘std::vector<std::__cxx11::basic_string<wchar_t> >::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
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())
Rationales:
- previously, <mstyle> was used, but it's being deprecated for MathML 4 Core in favour of CSS and <mrow> (not a big deal in itself)
- the whole box cannot be hosted within the same tag, because neither <mstyle> nor <mrow> can have text, they need an intermediate container, <mtext> (which cannot hold anything else that pure text)
- new behaviour: always output a container for the whole box that has the right attributes, i.e. an <mrow>; split the content of the cell to have text and other tags set apart (text in <mtext>, other tags left as they were)
Old behaviour, invalid MathML (2 to 4):
<mstyle XXX>text<mn>.</mn></mstyle>
New behaviour, valid MathML:
<mrow XXX><mtext>text</mtext><mn>.</mn></mrow>
The inset represents text (as opposed to maths in formulae). <m:mstyle> is used to give style to its children, it is not supposed to have any contents on its own.