mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Toc navigation doesn't work well with child document. This is the first part of the fix: the Toc item selection is properly done before the location of the child document.
Use case solved by this patch: 1) open EmbeddedObject.lyx 2) open the TOC widget (Uwe says it crashes there but I can't reproduce) 3) try to select an item previous to 6.2.2: crash because of an assertion: Assertion triggered in bool __cdecl lyx::operator <(const class lyx::CursorSlice &,const class lyx::CursorSlice &) by failing check "false" in file D:\LyXSVN\ly x-devel\src\CursorSlice.cpp:106 I think this patch will also solve bug 3616: http://bugzilla.lyx.org/show_bug.cgi?id=3616 * TocItem::child_: new member for child document; default to false. * TocBackend::item(): skip DocIterator comparison if item is in child docuemt. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18370 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
16d4022189
commit
d2649159ca
@ -37,8 +37,8 @@ using std::string;
|
||||
// TocItem implementation
|
||||
|
||||
TocItem::TocItem(ParConstIterator const & par_it, int d,
|
||||
docstring const & s)
|
||||
: par_it_(par_it), depth_(d), str_(s)
|
||||
docstring const & s, bool child)
|
||||
: par_it_(par_it), depth_(d), str_(s), child_(child)
|
||||
{
|
||||
/*
|
||||
if (!uid_.empty())
|
||||
@ -123,14 +123,10 @@ Toc const & TocBackend::toc(std::string const & type) const
|
||||
|
||||
void TocBackend::updateItem(ParConstIterator const & par_it)
|
||||
{
|
||||
if (toc("tableofcontents").empty()) {
|
||||
// TODO should not happen,
|
||||
// a call to TocBackend::update() is missing somewhere
|
||||
LYXERR(Debug::INFO)
|
||||
<< "TocBackend.cpp: TocBackend::updateItem"
|
||||
<< "called but the TOC is empty" << std::endl;
|
||||
// TODO should not happen,
|
||||
// a call to TocBackend::update() is missing somewhere
|
||||
if (toc("tableofcontents").empty())
|
||||
return;
|
||||
}
|
||||
|
||||
BufferParams const & bufparams = buffer_->params();
|
||||
const int min_toclevel = bufparams.getTextClass().min_toclevel();
|
||||
@ -174,6 +170,9 @@ void TocBackend::update()
|
||||
BufferParams const & bufparams = buffer_->params();
|
||||
const int min_toclevel = bufparams.getTextClass().min_toclevel();
|
||||
|
||||
// Is this a child document?
|
||||
bool const child_document = buffer_->getMasterBuffer() != buffer_;
|
||||
|
||||
Toc & toc = tocs_["tableofcontents"];
|
||||
ParConstIterator pit = buffer_->par_iterator_begin();
|
||||
ParConstIterator end = buffer_->par_iterator_end();
|
||||
@ -212,8 +211,8 @@ void TocBackend::update()
|
||||
// insert this into the table of contents
|
||||
if (tocstring.empty())
|
||||
tocstring = pit->asString(*buffer_, true);
|
||||
toc.push_back(
|
||||
TocItem(pit, toclevel - min_toclevel, tocstring));
|
||||
toc.push_back(TocItem(pit, toclevel - min_toclevel,
|
||||
tocstring, child_document));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,9 +241,12 @@ TocIterator const TocBackend::item(
|
||||
while (par_it_text.inMathed())
|
||||
par_it_text.backwardPos();
|
||||
|
||||
for (; it != last; --it)
|
||||
for (; it != last; --it) {
|
||||
if (it->child_)
|
||||
continue;
|
||||
if (it->par_it_ <= par_it_text)
|
||||
return it;
|
||||
}
|
||||
|
||||
// We are before the first Toc Item:
|
||||
return last;
|
||||
|
@ -41,7 +41,9 @@ public:
|
||||
///
|
||||
TocItem(ParConstIterator const & par_it = ParConstIterator(),
|
||||
int d = -1,
|
||||
docstring const & s = docstring());
|
||||
docstring const & s = docstring(),
|
||||
bool child = false
|
||||
);
|
||||
///
|
||||
~TocItem() {}
|
||||
///
|
||||
@ -67,6 +69,9 @@ protected:
|
||||
|
||||
/// Full item string
|
||||
docstring str_;
|
||||
|
||||
/// Set to true if the item comes from a child document.
|
||||
bool child_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user