From c0fad8643120a2a6fd9d62f7ab226798274b1cbb Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 30 Jan 2007 13:54:28 +0000 Subject: [PATCH] Fix bug 3177: http://bugzilla.lyx.org/show_bug.cgi?id=3177 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16949 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/TocBackend.C | 3 +++ src/frontends/qt4/QToc.C | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TocBackend.C b/src/TocBackend.C index fd714ce562..1101b968d9 100644 --- a/src/TocBackend.C +++ b/src/TocBackend.C @@ -203,6 +203,9 @@ TocIterator const TocBackend::item( Toc const & toc_vector = toclist_it->second; TocIterator last = toc_vector.begin(); TocIterator it = toc_vector.end(); + if (it == last) + return it; + --it; for (; it != last; --it) { diff --git a/src/frontends/qt4/QToc.C b/src/frontends/qt4/QToc.C index 840ce3a962..eeec2489aa 100644 --- a/src/frontends/qt4/QToc.C +++ b/src/frontends/qt4/QToc.C @@ -92,7 +92,7 @@ QModelIndex const QToc::getCurrentIndex() { vector const & types = getTypes(); TocIterator const it = getCurrentTocItem(types[type_]); - if (!it->isValid()) { + if (it == getContents(types[type_]).end() || !it->isValid()) { lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl; return QModelIndex(); } -- 2.39.5