+2004-05-04 Angus Leeming <leeming@lyx.org>
+
+ * math_scriptinset.C (up, down, notifyCursorLeaves): ensure that
+ accessor index is valid.
+
2004-05-04 Angus Leeming <leeming@lyx.org>
* formulamacro.C:
MathScriptInset::MathScriptInset(MathAtom const & at, bool up)
: MathNestInset(2), cell_1_is_up_(up), limits_(0)
{
+ BOOST_ASSERT(nargs() >= 1);
cell(0).push_back(at);
}
MathArray const & MathScriptInset::down() const
{
- return nargs() == 2 ? cell(2) : cell(1);
+#if 1
+ if (nargs() == 3)
+ return cell(2);
+ BOOST_ASSERT(nargs() > 1);
+ return cell(1);
+#else
+ return nargs() == 3 ? cell(2) : cell(1);
+#endif
}
MathArray & MathScriptInset::down()
{
- return nargs() == 2 ? cell(2) : cell(1);
+#if 1
+ if (nargs() == 3)
+ return cell(2);
+ BOOST_ASSERT(nargs() > 1);
+ return cell(1);
+#else
+ return nargs() == 3 ? cell(2) : cell(1);
+#endif
}
MathArray const & MathScriptInset::up() const
{
+ BOOST_ASSERT(nargs() > 1);
return cell(1);
}
MathArray & MathScriptInset::up()
{
+ BOOST_ASSERT(nargs() > 1);
return cell(1);
}
MathNestInset::notifyCursorLeaves(idx);
// remove empty scripts if possible
- if (idx == 2 && cell(2).empty()) {
+ if (idx == 2 && nargs() > 2 && cell(2).empty()) {
removeScript(false); // must be a subscript...
- } else if (idx == 1 && cell(1).empty()) {
+ } else if (idx == 1 && nargs() > 1 && cell(1).empty()) {
if (nargs() == 2) {
cell_1_is_up_ = false;
cell(1) = cell(2);