]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
cleanup error messages
[lyx.git] / src / Buffer.cpp
index d4a519004fdc45ab94f21d4584704bb52c31d750..1a37dcc2102d32f85b69a8cfafd3b4ebb9c1d450 100644 (file)
@@ -1417,9 +1417,7 @@ void Buffer::writeLyXHTMLSource(odocstream & os,
 {
        LaTeXFeatures features(*this, params(), runparams);
        validate(features);
-       // We are going to use some of this stuff ourselves,
-       // so make sure it is up to date.
-       updateLabels();
+       updateLabels(UpdateMaster, true);
 
        d->texrow.reset();
 
@@ -3442,7 +3440,7 @@ void Buffer::setBuffersForInsets() const
 }
 
 
-void Buffer::updateLabels(bool out, UpdateScope scope) const
+void Buffer::updateLabels(UpdateScope scope, bool out) const
 {
        // Use the master text class also for child documents
        Buffer const * const master = masterBuffer();
@@ -3456,7 +3454,7 @@ void Buffer::updateLabels(bool out, UpdateScope scope) const
                // If this is a child document start with the master
                if (master != this) {
                        bufToUpdate.insert(this);
-                       master->updateLabels(out);
+                       master->updateLabels(UpdateMaster, out);
                        // Do this here in case the master has no gui associated with it. Then, 
                        // the TocModel is not updated and TocModel::toc_ is invalid (bug 5699).
                        if (!master->gui_)
@@ -3737,15 +3735,26 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
        DocIterator const end = doc_iterator_end(this);
        for (; from != end; from.forwardPos()) {
                // We are only interested in text so remove the math CursorSlice.
-               while (from.inMathed())
-                       from.forwardInset();
+               while (from.inMathed()) {
+                       from.pop_back();
+                       from.pos()++;
+               }
+               // If from is at the end of the document (which is possible
+               // when leaving the mathed) LyX will crash later.
+               if (from == end)
+                       break;
                to = from;
                if (from.paragraph().spellCheck(from.pos(), to.pos(), wl, suggestions)) {
                        word_lang = wl;
                        break;
                }
-               from = to;
-               ++progress;
+
+               // Do not increase progress when from == to, otherwise the word
+               // count will be wrong.
+               if (from != to) {
+                       from = to;
+                       ++progress;
+               }
        }
        return progress;
 }