From 9b9080c0e9cc5e89afb572d0cda1dda021ed8627 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 27 Feb 2008 16:44:57 +0000 Subject: [PATCH] Bug fix: Adjustment for multiple reference to the same label. The solution is still not optimal as any reference to a label after the reference will not get notice. This is because addToToc() is called iteratively through the document so the toc entry for the label is still not created... any idea to fix this is welcome. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23285 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetRef.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index ddbff5ebb5..b9e7909b22 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -163,12 +163,19 @@ void InsetRef::addToToc(Buffer const & buf, Toc::const_iterator it = toc.begin(); Toc::const_iterator end = toc.end(); for (; it != end; ++it) { - if (it->str() == label) { - ++it; - toc.insert(it, TocItem(cpit, 1, getScreenLabel(buf))); + if (it->str() == label) break; - } } + + if (it == end) + //FIXME: this is an orphan, is this really possible? + return; + + docstring const reflabel = getScreenLabel(buf); + ++it; + while (it->str() == reflabel && it != end) + ++it; + toc.insert(it, TocItem(cpit, 1, reflabel)); }