]> git.lyx.org Git - features.git/commitdiff
Preliminary safeguard code to fix bug 3189.
authorAbdelrazak Younes <younes@lyx.org>
Thu, 8 Feb 2007 08:44:45 +0000 (08:44 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Thu, 8 Feb 2007 08:44:45 +0000 (08:44 +0000)
* DocIterator::prevInset(): return 0 if the mathed cell() is empty.

* LCursor::info(): use prevInset() only if different from zero.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17104 a592a061-630c-0410-9148-cb99ea01b6c8

src/cursor.C
src/dociterator.C

index ad749e3aaa35cdb5a14ae7a7ae0f84dc798cd96d..05fc44099a59a62c6bb0f6f5e7fd48d148756816 100644 (file)
@@ -510,6 +510,15 @@ void LCursor::setSelection(DocIterator const & where, int n)
 }
 
 
+void LCursor::setSelection(DocIterator const & from,
+               DocIterator const & to)
+{
+       setCursor(to);
+       selection() = true;
+       anchor_ = from;
+}
+
+
 void LCursor::clearSelection()
 {
        selection() = false;
@@ -543,8 +552,12 @@ void LCursor::info(odocstream & os) const
                operator[](i).inset().infoize(os);
                os << "  ";
        }
-       if (pos() != 0)
-               prevInset()->infoize2(os);
+       if (pos() != 0) {
+               InsetBase const * inset = prevInset();
+               // prevInset() can return 0 in certain case.
+               if (inset)
+                       prevInset()->infoize2(os);
+       }
        // overwite old message
        os << "                    ";
 }
index bb72fb6c2d71c669dffc61b936fc3a36c9e4beaa..ad96095022b2ebbc6b2340bd8bee89b2ff565897 100644 (file)
@@ -78,7 +78,13 @@ InsetBase * DocIterator::prevInset()
        if (pos() == 0)
                return 0;
        if (inMathed())
-               return prevAtom().nucleus();
+               if (cell().empty())
+                       // FIXME: this should not happen but it does.
+                       // See bug 3189
+                       // http://bugzilla.lyx.org/show_bug.cgi?id=3189
+                       return 0;
+               else
+                       return prevAtom().nucleus();
        return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
 }
 
@@ -89,7 +95,13 @@ InsetBase const * DocIterator::prevInset() const
        if (pos() == 0)
                return 0;
        if (inMathed())
-               return prevAtom().nucleus();
+               if (cell().empty())
+                       // FIXME: this should not happen but it does.
+                       // See bug 3189
+                       // http://bugzilla.lyx.org/show_bug.cgi?id=3189
+                       return 0;
+               else
+                       return prevAtom().nucleus();
        return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
 }