mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-05 13:26:21 +00:00
add some safeguards (while investigating bug 3152).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17421 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e69f006911
commit
566d80d064
@ -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<string> 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)));
|
||||
|
Loading…
Reference in New Issue
Block a user