Abdelrazak Younes wrote:
Juergen Spitzmueller wrote:
No, forget about this, I think I know the problem and your backtrace
is either due to a memory corruption or to another bug. The backtrace
is actually exactly the same as before and is due to a temporary
reference. Please try this patch and report back.
Hum, it looks like I didn't send the patch :-) Here it is.
FYI, the problem was that Paragraph::asString() used in
InsetCaption::addToToc() triggered the loading of child document which
were already in the loading process, thus creating a recursive call of
InsetInclude::addToToc(). This was due to a citation item inside one of
the caption. For a better understanding of the issue, here is the
backtrace that I manage to obtain via step by step debugging. Pretty
tricky stuff!
Abdel.
InsetInclude::addToToc(lyx::Buffer & buffer={...}, const
lyx::ParConstIterator & pit={...}) Ligne 922 C++
TocBackend::update() Ligne 158 + 0x23 octets C++
updateLabels(const lyx::Buffer & buf={...}, bool childonly=false) Ligne
717 C++
LyXView::loadLyXFile(const lyx::support::FileName & filename={...}, bool
tolastfiles=true, bool child_document=true, bool auto_open=true) Ligne
230 + 0x10 octets C++
LyXFunc::dispatch(const lyx::FuncRequest & cmd={...}) Ligne 1518 C++
dispatch(const lyx::FuncRequest & action={...}) Ligne 1514 C++
`anonymous namespace'::loadIfNeeded(const lyx::Buffer & buffer={...},
const lyx::InsetCommandParams & params={...}) Ligne 410 + 0x47
octets C++
InsetInclude::fillWithBibKeys() Ligne 742 + 0x10 octets C++
Buffer::fillWithBibKeys() Ligne 1375 + 0x10 octets C++
Buffer::fillWithBibKeys() Ligne 1364 C++
`anonymous namespace'::getNatbibLabel() Ligne 104 C++
InsetCitation::generateLabel(const lyx::Buffer & buffer={...}) Ligne
324 + 0x5f octets C++
InsetCitation::plaintext() Ligne 371 + 0x10 octets C++
InsetCitation::textString() Ligne 412 + 0x25 octets C++
Paragraph::asString() Ligne 2573 + 0x38 octets C++
Paragraph::asString() Ligne 2555 + 0x20 octets C++
InsetCaption::addToToc() Ligne 129 + 0x1c octets C++
TocBackend::update() Ligne 158 + 0x23 octets C++
InsetInclude::addToToc() Ligne 924 C++
TocBackend::update() Ligne 158 + 0x23 octets C++
updateLabels() Ligne 717 C++
LyXView::loadLyXFile() Ligne 230 + 0x10 octets C++
LyXFunc::dispatch(const lyx::FuncRequest & cmd={...}) Ligne 1518 C++
dispatch(const lyx::FuncRequest & action={...}) Ligne 1514 C++
`anonymous namespace'::loadIfNeeded(const lyx::Buffer & buffer={...},
const lyx::InsetCommandParams & params={...}) Ligne 410 + 0x47
octets C++
InsetInclude::getLabelList() Ligne 729 + 0x10 octets C++
Buffer::getLabelList() Ligne 1350 + 0x25 octets C++
Buffer::changeRefsIfUnique() Ligne 1785 C++
InsetLabel::doDispatch(lyx::Cursor & cur={...}, lyx::FuncRequest &
cmd={...}) Ligne 71 + 0x73 octets C++
Inset::dispatch(lyx::Cursor & cur={...}, lyx::FuncRequest & cmd={...})
Ligne 145 + 0x1a octets C++
LyXFunc::dispatch(const lyx::FuncRequest & cmd={...}) Ligne 1650 C++
dispatch(const lyx::FuncRequest & action={...}) Ligne 1514 C++
LyXView::dispatch(const lyx::FuncRequest & cmd={...}) Ligne 514 + 0x9
octets C++
frontend::Kernel::dispatch(const lyx::FuncRequest & fr={...}) Ligne
36 C++
frontend::ControlCommand::dispatchParams() Ligne 53 + 0x35 octets C++
frontend::Dialog::apply() Ligne 130 + 0x1a octets C++
frontend::Dialog::OKButton() Ligne 47 C++
frontend::QDialogView::slotOK() Ligne 109 C++
Index: insets/InsetCaption.cpp
===================================================================
--- insets/InsetCaption.cpp (revision 24874)
+++ insets/InsetCaption.cpp (working copy)
@@ -127,7 +127,7 @@
Toc & toc = toclist[type_];
docstring const str = convert<docstring>(counter_)
- + ". " + pit->asString(buf, false);
+ + ". " + pit->printableString(false);
toc.push_back(TocItem(pit, 0, str));
}
Index: Paragraph.cpp
===================================================================
--- Paragraph.cpp (revision 24874)
+++ Paragraph.cpp (working copy)
@@ -2548,6 +2548,21 @@
}
+docstring const Paragraph::printableString(bool label) const
+{
+ odocstringstream os;
+ if (label && !params().labelString().empty())
+ os << params().labelString() << ' ';
+ pos_type end = size();
+ for (pos_type i = 0; i < end; ++i) {
+ value_type const c = getChar(i);
+ if (isPrintable(c))
+ os.put(c);
+ }
+ return os.str();
+}
+
+
// Convert the paragraph to a string.
// Used for building the table of contents
docstring const Paragraph::asString(Buffer const & buffer, bool label) const
Index: Paragraph.h
===================================================================
--- Paragraph.h (revision 24874)
+++ Paragraph.h (working copy)
@@ -101,6 +101,8 @@
bool isMultiLingual(BufferParams const &) const;
///
+ docstring const Paragraph::printableString(bool label) const;
+ ///
docstring const asString(Buffer const &, bool label) const;
///
docstring const asString(Buffer const & buffer,
Index: TocBackend.cpp
===================================================================
--- TocBackend.cpp (revision 24874)
+++ TocBackend.cpp (working copy)
@@ -113,7 +113,7 @@
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
if (!toc_item->par_it_->getLabelstring().empty())
tocstring = toc_item->par_it_->getLabelstring()
+ ' ';
- tocstring += par.asString(*buffer_, false);
+ tocstring += par.printableString(false);
break;
}
}
@@ -122,7 +122,7 @@
if (toclevel != Layout::NOT_IN_TOC
&& toclevel >= min_toclevel
&& tocstring.empty())
- tocstring = toc_item->par_it_->asString(*buffer_, true);
+ tocstring = toc_item->par_it_->printableString(true);
const_cast<TocItem &>(*toc_item).str_ = tocstring;
}
@@ -158,7 +158,7 @@
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
if (!pit->getLabelstring().empty())
tocstring = pit->getLabelstring() + ' ';
- tocstring += par.asString(*buffer_, false);
+ tocstring += par.printableString(false);
break;
}
default:
@@ -172,7 +172,7 @@
&& toclevel >= min_toclevel) {
// insert this into the table of contents
if (tocstring.empty())
- tocstring = pit->asString(*buffer_, true);
+ tocstring = pit->printableString(true);
toc.push_back(TocItem(pit, toclevel - min_toclevel,
tocstring));
}