mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
Fix crash when cursor is in an empty script and the user clicks
in the text. * src/insets/insetbase.h (notifyCursorLeaves): return a bool indicating whether cursor is invalidated. * src/mathed/math_nestinset.C (notifyCursorLeaves): * src/mathed/math_hullinset.C (notifyCursorLeaves): adapt to prototype change. * src/mathed/math_scriptinset.[Ch] (notifyCursorLeaves): return true when an inset has been deleted. * src/BufferView.C (mouseSetCursor): do not call dEPM when cursor is invalidated by notifyCursorLeaves. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14796 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4d55c8b288
commit
020a793ef9
@ -322,11 +322,13 @@ void BufferView::mouseSetCursor(LCursor & cur)
|
||||
BOOST_ASSERT(&cur.bv() == this);
|
||||
|
||||
// Has the cursor just left the inset?
|
||||
bool badcursor = false;
|
||||
if (&cursor().inset() != &cur.inset())
|
||||
cursor().inset().notifyCursorLeaves(cursor());
|
||||
badcursor = cursor().inset().notifyCursorLeaves(cursor());
|
||||
|
||||
// do the dEPM magic if needed
|
||||
if (cursor().inTexted())
|
||||
// FIXME: move this to InsetText::notifyCursorLeaves?
|
||||
if (!badcursor && cursor().inTexted())
|
||||
cursor().text()->deleteEmptyParagraphMechanism(cur, cursor());
|
||||
|
||||
cursor() = cur;
|
||||
|
@ -170,7 +170,8 @@ public:
|
||||
/// number of columns in gridlike structures
|
||||
virtual size_t ncols() const { return 0; }
|
||||
/// is called when the cursor leaves this inset
|
||||
virtual void notifyCursorLeaves(LCursor &) {}
|
||||
// returns true if cursor is now invalid.
|
||||
virtual bool notifyCursorLeaves(LCursor &) { return false; }
|
||||
|
||||
/// request "external features"
|
||||
virtual void validate(LaTeXFeatures &) const {}
|
||||
|
@ -386,7 +386,7 @@ void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
|
||||
}
|
||||
|
||||
|
||||
void MathHullInset::notifyCursorLeaves(LCursor & cur)
|
||||
bool MathHullInset::notifyCursorLeaves(LCursor & cur)
|
||||
{
|
||||
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
|
||||
Buffer const & buffer = cur.buffer();
|
||||
@ -394,6 +394,7 @@ void MathHullInset::notifyCursorLeaves(LCursor & cur)
|
||||
preview_->addPreview(snippet, buffer);
|
||||
preview_->startLoading(buffer);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
OutputParams const &) const;
|
||||
|
||||
/// get notification when the cursor leaves this inset
|
||||
void notifyCursorLeaves(LCursor & cur);
|
||||
bool notifyCursorLeaves(LCursor & cur);
|
||||
///
|
||||
//bool insetAllowed(Code code) const;
|
||||
///
|
||||
|
@ -350,7 +350,7 @@ int MathNestInset::latex(Buffer const &, std::ostream & os,
|
||||
}
|
||||
|
||||
|
||||
void MathNestInset::notifyCursorLeaves(LCursor & /*cur*/)
|
||||
bool MathNestInset::notifyCursorLeaves(LCursor & /*cur*/)
|
||||
{
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning look here
|
||||
@ -379,6 +379,7 @@ void MathNestInset::notifyCursorLeaves(LCursor & /*cur*/)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
/// access to the lock
|
||||
void lock(bool);
|
||||
/// get notification when the cursor leaves this inset
|
||||
void notifyCursorLeaves(LCursor & cur);
|
||||
bool notifyCursorLeaves(LCursor & cur);
|
||||
|
||||
/// direct access to the cell
|
||||
MathArray & cell(idx_type);
|
||||
|
@ -555,7 +555,7 @@ void MathScriptInset::infoize2(std::ostream & os) const
|
||||
}
|
||||
|
||||
|
||||
void MathScriptInset::notifyCursorLeaves(LCursor & cur)
|
||||
bool MathScriptInset::notifyCursorLeaves(LCursor & cur)
|
||||
{
|
||||
MathNestInset::notifyCursorLeaves(cur);
|
||||
|
||||
@ -568,10 +568,12 @@ void MathScriptInset::notifyCursorLeaves(LCursor & cur)
|
||||
// must be a subscript...
|
||||
recordUndoInset(cur);
|
||||
removeScript(false);
|
||||
return true;
|
||||
} else if (cur.idx() == 1 && cell(1).empty()) {
|
||||
// must be a superscript...
|
||||
recordUndoInset(cur);
|
||||
removeScript(true);
|
||||
return true;
|
||||
}
|
||||
} else if (nargs() > 1 && cur.idx() == 1 && cell(1).empty()) {
|
||||
// could be either subscript or super script
|
||||
@ -587,9 +589,11 @@ void MathScriptInset::notifyCursorLeaves(LCursor & cur)
|
||||
tmpcur.pop();
|
||||
tmpcur.cell().erase(tmpcur.pos());
|
||||
tmpcur.cell().insert(tmpcur.pos(), ar);
|
||||
return true;
|
||||
}
|
||||
|
||||
//lyxerr << "MathScriptInset::notifyCursorLeaves: 2 " << cur << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,8 +121,8 @@ private:
|
||||
int ndes() const;
|
||||
/// where do we have to draw the scripts?
|
||||
bool hasLimits() const;
|
||||
/// clean up empty cells
|
||||
void notifyCursorLeaves(LCursor & cur);
|
||||
/// clean up empty cells and return true if a cell has been deleted.
|
||||
bool notifyCursorLeaves(LCursor & cur);
|
||||
|
||||
/// possible subscript (index 0) and superscript (index 1)
|
||||
bool cell_1_is_up_;
|
||||
|
Loading…
Reference in New Issue
Block a user