Hi all!

I tracked down the bug which let to the thread "lyxbreaker???".

When previewing is on and the user clicks on a previewed math inset,
the editXY() method of MathNestedInset gets called. This method
knows nothing about previews and searches among its cells for
an inset. Unfortunately these insets are not in the CoordCache when
previewing is on, triggering the assertion.

The following patch fixes the bug for me but is not necesarily the 
best approach. I jsut provided a method MathHullInset::editXY which
unconditionally goes to the first position of the inset if previewing
is enabled (same as navigating with the cursor).

There are some strange things happening if previewing is enabled,
the cursor is already in the inset and you click into it, but I won't look
into that.

Cheers
/Andreas

P.S. This is NOT the patch for the other bug I just reported!


Index: src/mathed/math_hullinset.C
=====================================
RCS file: /cvs/lyx/lyx-devel/src/mathed/math_hullinset.C,v
retrieving revision 1.160
diff -u -p -r1.160 math_hullinset.C
--- src/mathed/math_hullinset.C 2004/11/26 13:56:22     1.160
+++ src/mathed/math_hullinset.C 2005/02/04 02:20:15
@@ -1217,6 +1220,20 @@ void MathHullInset::edit(LCursor & cur,
 }


+InsetBase * MathHullInset::editXY(LCursor & cur, int x, int y) const
+{
+       lyxerr << "MathHullInset::editXY(): "
+              << (RenderPreview::status() == LyXRC::PREVIEW_ON) << endl;
+       if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
+               edit(cur, true);
+               return this;
+       }
+       else {
+               return MathNestInset::editXY(cur, x, y);
+       }
+}
+
+
 string const MathHullInset::editMessage() const
 {
        return _("Math editor mode");
Index: src/mathed/math_hullinset.h
=================================
RCS file: /cvs/lyx/lyx-devel/src/mathed/math_hullinset.h,v
retrieving revision 1.60
diff -u -p -r1.60 math_hullinset.h
--- src/mathed/math_hullinset.h 2004/11/24 21:58:41     1.60
+++ src/mathed/math_hullinset.h 2005/02/04 02:20:15
@@ -196,6 +196,8 @@ public:
        ///
        void edit(LCursor & cur, bool left);
        ///
+       InsetBase * editXY(LCursor & cur, int x, int y) const;
+       ///
        bool display() const;
        ///
        Code lyxCode() const;


Reply via email to