Prevent Outliner crash due to emptied toc value

This might need a more profound fix in the long term, see
https://marc.info/?l=lyx-devel&m=163588729224679&w=2
This commit is contained in:
Juergen Spitzmueller 2021-12-04 17:53:03 +01:00
parent 5eecfa3e04
commit 31146ae8d3
2 changed files with 7 additions and 0 deletions

View File

@ -327,6 +327,11 @@ TocItem const TocModels::currentItem(QString const & type,
}
LASSERT(index.model() == it.value()->model(), return TocItem());
if (it.value()->empty()) {
LYXERR(Debug::GUI, "TocModels::currentItem(): requested toc is empty!");
return TocItem();
}
return it.value()->tocItem(index);
}

View File

@ -47,6 +47,8 @@ public:
///
void clear();
///
bool empty() { return toc_->empty(); }
///
QAbstractItemModel * model();
///
QAbstractItemModel const * model() const;