From 566d80d064886e922b7856e4c91861ce15aab8ec Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 12 Mar 2007 17:03:42 +0000 Subject: [PATCH] add some safeguards (while investigating bug 3152). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17421 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QToc.C | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/frontends/qt4/QToc.C b/src/frontends/qt4/QToc.C index a6885d0dcd..505e6153d4 100644 --- a/src/frontends/qt4/QToc.C +++ b/src/frontends/qt4/QToc.C @@ -53,6 +53,8 @@ bool QToc::canOutline() int QToc::getTocDepth() { + if (type_ < 0) + return 0; return toc_models_[type_]->modelDepth(); } @@ -91,6 +93,9 @@ QStandardItemModel * QToc::setTocModel(int type) QModelIndex const QToc::getCurrentIndex() { vector const & types = getTypes(); + if (types.empty() || type_ < 0) + return QModelIndex(); + TocIterator const it = getCurrentTocItem(types[type_]); if (it == getContents(types[type_]).end() || !it->isValid()) { lyxerr[Debug::GUI] << "QToc::getCurrentIndex(): TocItem is invalid!" << endl; @@ -110,6 +115,8 @@ void QToc::goTo(QModelIndex const & index) return; } + BOOST_ASSERT(type_ >= 0 && type_ < int(toc_models_.size())); + TocIterator const it = toc_models_[type_]->tocIterator(index); lyxerr[Debug::GUI] @@ -154,6 +161,7 @@ void QToc::updateType() selected_type = to_ascii(params()["type"]); QString gui_names_; + type_ = -1; for (size_t i = 0; i != types.size(); ++i) { string const & type_str = types[i]; type_list.append(toqstr(getGuiName(type_str))); -- 2.39.5