Jean-Marc Lasgouttes wrote:
"Elazar" == Elazar Leibovich <[EMAIL PROTECTED]> writes:

Elazar> Please note the following strange piece of code from
Elazar> inset.h:404 which causes the problem: virtual LyXText *
Elazar> getText(int /*num*/) const { return 0; } That is, when you're
Elazar> asking an inset to recieve its text you're getting NULL,
Elazar> however, the CursorSlice object uses (inset_.getText()) in
Elazar> order to return it's paragraph. Obviously when null object is
Elazar> used - segfaults occurs. I just don't know the code enough to
Elazar> fix it.
I think one needs cur.innerText().

We need the innerParagraph (see attached).

Abdel.


Index: Cursor.cpp
===================================================================
--- Cursor.cpp  (revision 18099)
+++ Cursor.cpp  (working copy)
@@ -1329,6 +1329,9 @@
 
 bool Cursor::isRTL() const
 {
+       if (inMathed())
+               return 
innerParagraph().isRightToLeftPar(bv().buffer()->params());
+
        return top().paragraph().isRightToLeftPar(bv().buffer()->params());
 }
 
Index: DocIterator.cpp
===================================================================
--- DocIterator.cpp     (revision 18099)
+++ DocIterator.cpp     (working copy)
@@ -181,6 +181,22 @@
 }
 
 
+Paragraph const & DocIterator::innerParagraph() const
+{
+       BOOST_ASSERT(!empty());
+       // go up until first non-0 text is hit
+       // (innermost text is 0 in mathed)
+       for (int i = depth() - 1; i >= 0; --i)
+               if (slices_[i].text())
+                       return slices_[i].paragraph();
+
+       // This case is in principe not possible. We _must_
+       // we inside a Paragraph.
+       BOOST_ASSERT(false);
+       return paragraph();
+}
+
+
 pit_type DocIterator::lastpit() const
 {
        return inMathed() ? 0 : text()->paragraphs().size() - 1;
@@ -257,6 +273,7 @@
        return 0;
 }
 
+
 LyXText const * DocIterator::innerText() const
 {
        BOOST_ASSERT(!empty());
Index: DocIterator.h
===================================================================
--- DocIterator.h       (revision 18099)
+++ DocIterator.h       (working copy)
@@ -155,8 +155,13 @@
        //
        /// the paragraph we're in
        Paragraph & paragraph();
-       /// the paragraph we're in
+       /// the paragraph we're in in text mode.
+       /// \warning only works within text!
        Paragraph const & paragraph() const;
+       /// the paragraph we're in in any case.
+       /// This method will give the containing paragraph if
+       /// in not in text mode (ex: in mathed).
+       Paragraph const & innerParagraph() const;
        ///
        LyXText * text();
        ///

Reply via email to