]> git.lyx.org Git - features.git/commitdiff
Don't asssert on (too) deeply nested items
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 5 Mar 2022 13:17:37 +0000 (14:17 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 5 Mar 2022 13:17:37 +0000 (14:17 +0100)
Use a fallback label instead.

src/BufferParams.cpp

index 95aa9136d25c59ce5aad57f45b9ebb6bc17bd453..b1846beaa3a24a87aeef673a92aef08791f7ee2b 100644 (file)
@@ -633,29 +633,45 @@ bool BufferParams::spellignored(WordLangTuple const & wl) const
 
 Bullet & BufferParams::temp_bullet(lyx::size_type const index)
 {
-       LASSERT(index < 4, return pimpl_->temp_bullets[0]);
-       return pimpl_->temp_bullets[index];
+       if (index < 4)
+               return pimpl_->temp_bullets[index];
+       // Fallback bullet if we are too deeply nested
+       docstring const fb = from_ascii("?") + convert<docstring>(index + 1);
+       Bullet const & res = Bullet(fb);
+       return const_cast<Bullet&>(res);
 }
 
 
 Bullet const & BufferParams::temp_bullet(lyx::size_type const index) const
 {
-       LASSERT(index < 4, return pimpl_->temp_bullets[0]);
-       return pimpl_->temp_bullets[index];
+       if (index < 4)
+               return pimpl_->temp_bullets[index];
+       // Fallback bullet if we are too deeply nested
+       docstring const fb = from_ascii("?") + convert<docstring>(index + 1);
+       Bullet const & res = Bullet(fb);
+       return res;
 }
 
 
 Bullet & BufferParams::user_defined_bullet(lyx::size_type const index)
 {
-       LASSERT(index < 4, return pimpl_->temp_bullets[0]);
-       return pimpl_->user_defined_bullets[index];
+       if (index < 4)
+               return pimpl_->user_defined_bullets[index];
+       // Fallback bullet if we are too deeply nested
+       docstring const fb = from_ascii("?") + convert<docstring>(index + 1);
+       Bullet const & res = Bullet(fb);
+       return const_cast<Bullet&>(res);
 }
 
 
 Bullet const & BufferParams::user_defined_bullet(lyx::size_type const index) const
 {
-       LASSERT(index < 4, return pimpl_->temp_bullets[0]);
-       return pimpl_->user_defined_bullets[index];
+       if (index < 4)
+               return pimpl_->user_defined_bullets[index];
+       // Fallback bullet if we are too deeply nested
+       docstring const fb = from_ascii("?") + convert<docstring>(index + 1);
+       Bullet const & res = Bullet(fb);
+       return res;
 }