[LyX/master] Prevent Outliner crash due to emptied toc value
Juergen Spitzmueller
spitz at lyx.org
Sat Dec 4 16:28:05 UTC 2021
commit 31146ae8d3c058f33931ba40ad36b6ad9c588195
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sat Dec 4 17:53:03 2021 +0100
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
---
src/frontends/qt/TocModel.cpp | 5 +++++
src/frontends/qt/TocModel.h | 2 ++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/frontends/qt/TocModel.cpp b/src/frontends/qt/TocModel.cpp
index 16990b8..c0c3dce 100644
--- a/src/frontends/qt/TocModel.cpp
+++ b/src/frontends/qt/TocModel.cpp
@@ -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);
}
diff --git a/src/frontends/qt/TocModel.h b/src/frontends/qt/TocModel.h
index 55507a0..ee44761 100644
--- a/src/frontends/qt/TocModel.h
+++ b/src/frontends/qt/TocModel.h
@@ -47,6 +47,8 @@ public:
///
void clear();
///
+ bool empty() { return toc_->empty(); }
+ ///
QAbstractItemModel * model();
///
QAbstractItemModel const * model() const;
More information about the lyx-cvs
mailing list