]> git.lyx.org Git - lyx.git/blobdiff - src/dociterator.C
Scons: update_po target, part one: language_l10n.pot
[lyx.git] / src / dociterator.C
index 5f8ace8f6594c35f4424e23dd6ee1997e62f665f..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;
 }
 
@@ -274,11 +286,12 @@ void DocIterator::forwardPos(bool ignorecollapsed)
                return;
        }
 
+       InsetBase * const nextinset = nextInset();
        // jump over collapsables if they are collapsed
        // FIXME: the check for asInsetMath() shouldn't be necessary
        // but math insets do not return a sensible editable() state yet.
-       if (ignorecollapsed && nextInset() && (!nextInset()->asInsetMath()
-           && nextInset()->editable() != InsetBase::HIGHLY_EDITABLE)) {
+       if (ignorecollapsed && nextinset && (!nextinset->asInsetMath()
+           && nextinset->editable() != InsetBase::HIGHLY_EDITABLE)) {
                ++top().pos();
                return;
        }
@@ -297,9 +310,8 @@ void DocIterator::forwardPos(bool ignorecollapsed)
                if (inMathed()) {
                        n = (tip.cell().begin() + tip.pos())->nucleus();
                } else {
-                       // InsetList::get() will return a null pointer if there's
-                       // no inset at this position.
-                       n = paragraph().getInset(tip.pos());
+                       if (paragraph().isInset(tip.pos()))
+                               n = paragraph().getInset(tip.pos());
                }
        }