mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* fix segfaults/asserts when clicking outside of any inset when the
cursor is inside of an empty script. * Do not use the cur parameter of notifyCursorLeaves as a pointer to the script inset. It is not. Even worth, it's an empty cursor if the user clicks in the grey nirvana of the BufferView. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22910 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
59e75f8cb5
commit
c4b009a248
@ -10,16 +10,18 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "Cursor.h"
|
||||||
|
#include "DispatchResult.h"
|
||||||
|
#include "FuncRequest.h"
|
||||||
|
#include "InsetMathFont.h"
|
||||||
#include "InsetMathScript.h"
|
#include "InsetMathScript.h"
|
||||||
|
#include "InsetMathSymbol.h"
|
||||||
#include "MathData.h"
|
#include "MathData.h"
|
||||||
#include "MathStream.h"
|
#include "MathStream.h"
|
||||||
#include "MathSupport.h"
|
#include "MathSupport.h"
|
||||||
#include "InsetMathSymbol.h"
|
|
||||||
#include "InsetMathFont.h"
|
|
||||||
#include "DispatchResult.h"
|
|
||||||
#include "Cursor.h"
|
|
||||||
#include "support/debug.h"
|
#include "support/debug.h"
|
||||||
#include "FuncRequest.h"
|
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
@ -671,13 +673,11 @@ bool InsetMathScript::notifyCursorLeaves(Cursor & cur)
|
|||||||
if (nargs() > 2 && (!cell(1).empty() || !cell(2).empty())) {
|
if (nargs() > 2 && (!cell(1).empty() || !cell(2).empty())) {
|
||||||
if (cell(2).empty()) {
|
if (cell(2).empty()) {
|
||||||
// must be a subscript...
|
// must be a subscript...
|
||||||
cur.recordUndoInset();
|
|
||||||
removeScript(false);
|
removeScript(false);
|
||||||
cur.updateFlags(cur.disp_.update() | Update::SinglePar);
|
cur.updateFlags(cur.disp_.update() | Update::SinglePar);
|
||||||
return true;
|
return true;
|
||||||
} else if (cell(1).empty()) {
|
} else if (cell(1).empty()) {
|
||||||
// must be a superscript...
|
// must be a superscript...
|
||||||
cur.recordUndoInset();
|
|
||||||
removeScript(true);
|
removeScript(true);
|
||||||
cur.updateFlags(cur.disp_.update() | Update::SinglePar);
|
cur.updateFlags(cur.disp_.update() | Update::SinglePar);
|
||||||
return true;
|
return true;
|
||||||
@ -689,18 +689,25 @@ bool InsetMathScript::notifyCursorLeaves(Cursor & cur)
|
|||||||
// The script inset is removed completely.
|
// The script inset is removed completely.
|
||||||
if ((nargs() == 2 && cell(1).empty())
|
if ((nargs() == 2 && cell(1).empty())
|
||||||
|| (nargs() == 3 && cell(1).empty() && cell(2).empty())) {
|
|| (nargs() == 3 && cell(1).empty() && cell(2).empty())) {
|
||||||
// could be either subscript or super script
|
// Make undo step. We cannot use cur for this because
|
||||||
cur.recordUndoInset();
|
// it does not necessarily point to us. The BufferView
|
||||||
|
// cursor though should do.
|
||||||
|
int scriptSlice
|
||||||
|
= cur.bv().cursor().find(this);
|
||||||
|
BOOST_ASSERT(scriptSlice != -1);
|
||||||
|
Cursor scriptCur = cur.bv().cursor();
|
||||||
|
scriptCur.cutOff(scriptSlice);
|
||||||
|
scriptCur.recordUndoInset();
|
||||||
|
|
||||||
// Let the script inset commit suicide. This is
|
// Let the script inset commit suicide. This is
|
||||||
// modelled on Cursor.pullArg(), but tries not to
|
// modelled on Cursor.pullArg(), but tries not to
|
||||||
// invoke notifyCursorLeaves again and does not touch
|
// invoke notifyCursorLeaves again and does not touch
|
||||||
// cur (since the top slice will be deleted
|
// cur (since the top slice will be deleted
|
||||||
// afterwards))
|
// afterwards)
|
||||||
MathData ar = cell(0);
|
MathData ar = cell(0);
|
||||||
Cursor tmpcur = cur;
|
scriptCur.pop();
|
||||||
tmpcur.pop();
|
scriptCur.cell().erase(scriptCur.pos());
|
||||||
tmpcur.cell().erase(tmpcur.pos());
|
scriptCur.cell().insert(scriptCur.pos(), ar);
|
||||||
tmpcur.cell().insert(tmpcur.pos(), ar);
|
|
||||||
cur.updateFlags(cur.disp_.update() | Update::SinglePar);
|
cur.updateFlags(cur.disp_.update() | Update::SinglePar);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user