for...@lyx.org wrote:
Author: forenr
Date: Mon Nov 16 00:54:45 2009
New Revision: 32037
URL: http://www.lyx.org/trac/changeset/32037
Log:
Fix bug #6208: macro crash.
The fix consists in not updating the macro while it is being edited,
and this is accomplished by the changes in MathData::updateMacros().
However, when clicking away with the mouse I was getting another crash,
which is cured by the changes in MathMacro::notifyCursorLeaves().
Modified:
lyx-devel/trunk/src/mathed/MathData.cpp
lyx-devel/trunk/src/mathed/MathMacro.cpp
Modified: lyx-devel/trunk/src/mathed/MathData.cpp
==============================================================================
--- lyx-devel/trunk/src/mathed/MathData.cpp Mon Nov 16 00:53:40 2009
(r32036)
+++ lyx-devel/trunk/src/mathed/MathData.cpp Mon Nov 16 00:54:45 2009
(r32037)
@@ -379,11 +379,18 @@
void MathData::updateMacros(Cursor * cur, MacroContext const & mc)
{
+ // If we are editing a macro, we cannot update it immediately,
+ // as no undo steps will be recorded (bug 6208).
+ InsetMath const * inmath = cur ? cur->inset().asInsetMath() : 0;
+ MathMacro const * inmacro = inmath ? inmath->asMacro() : 0;
+ docstring const edited_name = inmacro ? inmacro->name() : docstring();
+
// go over the array and look for macros
for (size_t i = 0; i < size(); ++i) {
MathMacro * macroInset = operator[](i).nucleus()->asMacro();
macro_inset
Modified: lyx-devel/trunk/src/mathed/MathMacro.cpp
==============================================================================
--- lyx-devel/trunk/src/mathed/MathMacro.cpp Mon Nov 16 00:53:40 2009
(r32036)
+++ lyx-devel/trunk/src/mathed/MathMacro.cpp Mon Nov 16 00:54:45 2009
(r32037)
@@ -633,15 +633,16 @@
docstring const & unfolded_name = name();
if (unfolded_name != name_) {
// The macro name was changed
- cur = old;
- bool left = cur.pos() == 0;
- cur.recordUndoInset();
- cur.popForward();
- cur.backspace();
- cur.insert(createInsetMath(unfolded_name,
cur.buffer()));
- if (left)
- cur.backwardPos();
- cur.updateFlags(Update::Force);
+ Cursor insetCur = old;
inset_cursor
Abdel.