Hi!

Here is a patch for a crash that happens due to a cell not in the coord cache during the drawing of the selection. It could be that this is related (and also fixes) http://bugzilla.lyx.org/show_bug.cgi? id=3715 .

I believe the problem is when an inset derived from InsetMathNest does not draw all its cells, and hence a cell is not in the coord cache yet. Then the warm up call in InsetMathNest::drawSelection cannot get the cell into the cache and the loop over all cells at the bottom of this very function will trigger an assertion.

You can trigger this crash in Beta 3 or 1.5svn like this:

New document, Ctrl-M \ref <space> <shift-right>

With this patch the <shift-right> seems to have no effect. Haven't checked why. But at least the segfault is gone.

Stefan

Index: src/mathed/InsetMathNest.cpp
===================================================================
--- src/mathed/InsetMathNest.cpp        (Revision 18579)
+++ src/mathed/InsetMathNest.cpp        (Arbeitskopie)
@@ -251,11 +251,15 @@
                for (idx_type i = 0; i < nargs(); ++i) {
                        if (idxBetween(i, s1.idx(), s2.idx())) {
                                MathData const & c = cell(i);
-                               int x1 = c.xo(bv);
-                               int y1 = c.yo(bv) - c.ascent();
-                               int x2 = c.xo(bv) + c.width();
-                               int y2 = c.yo(bv) + c.descent();
-                               pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, 
Color::selection);
+                               // if the cell is not in the cache, it is 
probably not drawn,
+                               // and therefore not warmed up above. So skip 
the selection!
+                               if (bv.coordCache().arrays().has(&c)) {
+                                       int x1 = c.xo(bv);
+                                       int y1 = c.yo(bv) - c.ascent();
+                                       int x2 = c.xo(bv) + c.width();
+                                       int y2 = c.yo(bv) + c.descent();
+                                       pi.pain.fillRectangle(x1, y1, x2 - x1, 
y2 - y1, Color::selection);
+                               }
                        }
                }
        }


Attachment: refcrash.patch
Description: Binary data

Attachment: PGP.sig
Description: Signierter Teil der Nachricht

Reply via email to