]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetText.cpp
Fix crash after undo following replacement of a multicell selection (#8973).
[lyx.git] / src / insets / InsetText.cpp
index 157d2f9cd694ecf07a35677bf060d38c89215963..5f44052b4521d65173fa2170caabda945e61f112 100644 (file)
@@ -125,7 +125,7 @@ void InsetText::setMacrocontextPositionRecursive(DocIterator const & pos)
 void InsetText::clear()
 {
        ParagraphList & pars = paragraphs();
-       LASSERT(!pars.empty(), /**/);
+       LBUFERR(!pars.empty());
 
        // This is a gross hack...
        Layout const & old_layout = pars.begin()->layout();
@@ -815,6 +815,13 @@ void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
 {
        DocIterator dit = cdit;
        dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
+       iterateForToc(dit, output_active);
+}
+
+
+void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) const
+{
+       DocIterator dit = cdit;
        Toc & toc = buffer().tocBackend().toc("tableofcontents");
 
        BufferParams const & bufparams = buffer_->params();
@@ -847,7 +854,7 @@ void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
                if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
                        // insert this into the table of contents
                        docstring tocstring;
-                       int const length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
+                       int const length = doing_output ? INT_MAX : TOC_ENTRY_LENGTH;
                        if (arginset) {
                                tocstring = par.labelString();
                                if (!tocstring.empty())
@@ -857,7 +864,7 @@ void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
                                par.forToc(tocstring, length);
                        dit.pos() = 0;
                        toc.push_back(TocItem(dit, toclevel - min_toclevel,
-                               tocstring, output_active, tocstring));
+                               tocstring, doing_output, tocstring));
                }
                
                // And now the list of changes.
@@ -874,9 +881,11 @@ bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
        // find text inset in old cursor
        Cursor insetCur = old;
        int scriptSlice = insetCur.find(this);
-       LASSERT(scriptSlice != -1, /**/);
+       // we can try to continue here. returning true means
+       // the cursor is "now" invalid. which it was.
+       LASSERT(scriptSlice != -1, return true);
        insetCur.cutOff(scriptSlice);
-       LASSERT(&insetCur.inset() == this, /**/);
+       LASSERT(&insetCur.inset() == this, return true);
        
        // update the old paragraph's words
        insetCur.paragraph().updateWords();
@@ -887,7 +896,7 @@ bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
 
 bool InsetText::completionSupported(Cursor const & cur) const
 {
-       //LASSERT(&cur.bv().cursor().inset() != this, return false);
+       //LASSERT(&cur.bv().cursor().inset() == this, return false);
        return text_.completionSupported(cur);
 }