commit 4277e8b7336848cf36fe12ade610cf6c0ae6ff7f
Author: Richard Heck <[email protected]>
Date:   Mon Feb 24 14:36:13 2014 -0500

    Table cells are insets, but not from the point of view of DocIterators
    and Cursors. So just calling InsetText::addToToc for the cells causes
    problems, because InsetText::addToToc then adds the cell inset itself
    as part of the DocIterator. This then leads to assertions, such as bug
    
    The solution is to refactor InsetText::addToToc so that we can call the
    iterating part without adding the inset.
    (cherry picked from commit 6a85db2307d04581b2e6146b399ab863277f53c1)

diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index ac82d35..5b4660b 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -3373,6 +3373,12 @@ docstring InsetTableCell::asString(bool intoInsets)
 }
 
 
+void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
+{
+       InsetText::iterateForToc(di, output_active);
+}
+
+
 docstring InsetTableCell::xhtml(XHTMLStream & xs, OutputParams const & rp) 
const
 {
        if (!isFixedWidth)
diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h
index 2049e54..349261d 100644
--- a/src/insets/InsetTabular.h
+++ b/src/insets/InsetTabular.h
@@ -68,6 +68,8 @@ public:
        docstring asString(bool intoInsets = true);
        ///
        docstring xhtml(XHTMLStream &, OutputParams const &) const;
+       ///
+       void addToToc(DocIterator const & di, bool output_active) const;
 private:
        /// unimplemented
        InsetTableCell();
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 5c0c113..05e0c21 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -727,6 +727,13 @@ void InsetText::addToToc(DocIterator const & cdit) 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();
diff --git a/src/insets/InsetText.h b/src/insets/InsetText.h
index 704194c..1b1fc97 100644
--- a/src/insets/InsetText.h
+++ b/src/insets/InsetText.h
@@ -215,6 +215,8 @@ protected:
        docstring getCaptionText(OutputParams const &) const;
        ///
        docstring getCaptionHTML(OutputParams const &) const;
+       ///
+       void iterateForToc(DocIterator const & cdit, bool output_active) const;
 private:
        ///
        bool drawFrame_;
diff --git a/status.20x b/status.20x
index c5f5c80..b227cd1 100644
--- a/status.20x
+++ b/status.20x
@@ -73,6 +73,8 @@ What's new
 - Fix outliner-related crash when master and child are open in different
   windows (bug 8948).
 
+- Fix outliner-related crash involving captions in long tables (bug 8997).
+
 - Fix hang when using BibTeX files with really long author lists (bug 8944).
 
 - Fix crash with changetracking in bibliography environment (bug 8646).

Reply via email to