commit 820d9d84e6540efd3aff8610f19722677f0d5de3
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Jan 7 08:29:12 2026 +0100
counter stack might be legally empty
---
src/Buffer.cpp | 3 ++-
src/Counters.cpp | 8 +++++---
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 88ba8d0c9e..e042e5713e 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5339,7 +5339,8 @@ void Buffer::Impl::setLabel(ParIterator & it, ParIterator
& prev_it,
}
// restore previous counter after environmental counter
- if (prev_it != it && prev_par.params().depth() >= par.params().depth()
+ if (!counters.currentCounter().empty()
+ && prev_it != it && prev_par.params().depth() >=
par.params().depth()
&& prev_par.layout().isEnvironment()
&& (prev_par.layout().labeltype == LABEL_ENUMERATE
|| !prev_par.layout().counter.empty())
diff --git a/src/Counters.cpp b/src/Counters.cpp
index a93274558a..d211046823 100644
--- a/src/Counters.cpp
+++ b/src/Counters.cpp
@@ -400,8 +400,8 @@ void Counters::step(docstring const & ctr, UpdateType /*
deleted */, bool const
step(it->second.stepOtherCounter(), InternalUpdate, false);
if (set_active) {
- LBUFERR(!counter_stack_.empty());
- counter_stack_.pop_back();
+ if (!counter_stack_.empty())
+ counter_stack_.pop_back();
counter_stack_.push_back(ctr);
}
@@ -703,7 +703,9 @@ docstring Counters::prettyCounter(docstring const & name,
docstring Counters::currentCounter() const
{
- LBUFERR(!counter_stack_.empty());
+ if (counter_stack_.empty())
+ return docstring();
+
return counter_stack_.back();
}
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs