#include "TextMetrics.h"
#include "TocBackend.h"
-#include "support/lassert.h"
#include "support/debug.h"
#include "support/docstream.h"
+#include "support/ExceptionMessage.h"
+#include "support/gettext.h"
+#include "support/lassert.h"
#include "insets/InsetTabular.h"
#include "insets/InsetText.h"
}
*/
-
+/*
/// moves position closest to (x, y) in given box
bool bruteFind3(Cursor & cur, int x, int y, bool up)
{
cur.setCursor(best_cursor);
return true;
}
-
+*/
} // namespace anon
bool res = false;
for ( ; cur.depth(); cur.pop()) {
//lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
+ // LASSERT: Is it safe to continue here, or should we return?
LASSERT(cur.idx() <= cur.lastidx(), /**/);
LASSERT(cur.pit() <= cur.lastpit(), /**/);
LASSERT(cur.pos() <= cur.lastpos(), /**/);
for (; depth(); pop(), boundary(false)) {
LYXERR(Debug::DEBUG, "Cursor::dispatch: cmd: "
<< cmd0 << endl << *this);
- LASSERT(pos() <= lastpos(), /**/);
- LASSERT(idx() <= lastidx(), /**/);
- LASSERT(pit() <= lastpit(), /**/);
+
+ // In any of these cases, the cursor is invalid, and we should
+ // try to save this document rather than crash.
+ LBUFERR(pos() <= lastpos());
+ LBUFERR(idx() <= lastidx());
+ LBUFERR(pit() <= lastpit());
// The common case is 'LFUN handled, need update', so make the
// LFUN handler's life easier by assuming this as default value.
BufferView & Cursor::bv() const
{
- LASSERT(bv_, /**/);
+ LBUFERR(bv_);
return *bv_;
}
void Cursor::pop()
{
- LASSERT(depth() >= 1, /**/);
+ LBUFERR(depth() >= 1);
pop_back();
}
int Cursor::currentMode()
{
- LASSERT(!empty(), /**/);
+ LASSERT(!empty(), return Inset::UNDECIDED_MODE);
for (int i = depth() - 1; i >= 0; --i) {
int res = operator[](i).inset().currentMode();
bool locked_mode = operator[](i).inset().lockedMode();
{
CursorSlice const & cs = innerTextSlice();
ParagraphMetrics const & pm = bv().parMetrics(cs.text(), cs.pit());
- LASSERT(!pm.rows().empty(), /**/);
return pm.getRow(pos(), boundary());
}
{
if (!selection())
return top();
- LASSERT(anchor_.depth() >= depth(), /**/);
+ // LASSERT: There have been several bugs around this code, that seem
+ // to involve failures to reset the anchor. We can at least not crash
+ // in release mode by resetting it ourselves.
+ LASSERT(anchor_.depth() >= depth(),
+ const_cast<DocIterator &>(anchor_) = *this);
+
CursorSlice normal = anchor_[depth() - 1];
if (depth() < anchor_.depth() && top() <= normal) {
// anchor is behind cursor -> move anchor behind the inset
void Cursor::insert(char_type c)
{
//lyxerr << "Cursor::insert char '" << c << "'" << endl;
- LASSERT(!empty(), /**/);
+ LASSERT(!empty(), return);
if (inMathed()) {
cap::selClearOrDel(*this);
insert(new InsetMathChar(c));
void Cursor::insert(Inset * inset0)
{
- LASSERT(inset0, /**/);
+ LASSERT(inset0, return);
if (inMathed())
insert(MathAtom(inset0->asInsetMath()));
else {
bool Cursor::upDownInText(bool up, bool & updateNeeded)
{
- LASSERT(text(), /**/);
+ LASSERT(text(), return false);
// where are we?
int xo = 0;
updateNeeded |= bv().checkDepm(dummy, *this);
updateTextTargetOffset();
- if (updateNeeded) {
+ if (updateNeeded)
forceBufferUpdate();
- // DEPM may have requested a screen update
- this->screenUpdateFlags(
- this->screenUpdate() | dummy.screenUpdate());
- }
}
return false;
}
++dummy.pos();
if (bv().checkDepm(dummy, old)) {
updateNeeded = true;
- // Make sure that cur gets back whatever happened to dummy (Lgb)
- // This will include any screen update requested by DEPM
+ // Make sure that cur gets back whatever happened to dummy (Lgb)
operator=(dummy);
}
} else {