Am Mittwoch, 1. Februar 2006 23:20 schrieb Beck, Andrew Thomas - BECAT001:
> >
> >> Here is a patch to fix bug 2060 - again.
> >
> >It looks sensible. Are you sure that nothing needs to be done in
cursorPos
> >and drawSelection?
>
> Nope, I have no idea. I looked at your original patch which mentioned
> fixing a potential problem, but can't see how that would eventuate.
These fixes were necessary because MathNestInset requires at least one
cell, and a macro may have 0. I said 'potential problem' because we never
experienced problems with these methods in practice.
> If you can point out a scenario, I can test & fix it if required.
I have none, I only wanted to make sure that you did not oversee
something.
> I clicked on a closed macro. It opened the macro for editing. The first
cursor
> was in the first cell.
>
> Having first opened a macro with multiple cells for editing, I then
clicked
> around within the inset, selecting other cells.
Ok, I see now. Unfortunately your patch is not correct IMHO: If I click on
argument 3 I expect the cursor to appear in argument 3, not in the first
one as your patch does. In perinciple it is ok to call
MathNestInset::editXY, the problem is that the coordcache is not filled
for the cells, and therefore we get the crash.
A proper fix would therefore fill the coordcache, and then call
MathNestInset::editXY.
I tried the attached. It fixes the crash, but it also draws additional
numbers. I don't know why, since I use the nullpainter for dummy drawing.
Maybe you find it out?
Georg
Index: src/mathed/math_macro.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macro.C,v
retrieving revision 1.136
diff -u -p -r1.136 math_macro.C
--- src/mathed/math_macro.C 5 Oct 2005 21:19:32 -0000 1.136
+++ src/mathed/math_macro.C 2 Feb 2006 21:48:55 -0000
@@ -21,6 +21,7 @@
#include "debug.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
+#include "frontends/nullpainter.h"
#include "frontends/Painter.h"
using std::string;
@@ -105,6 +106,13 @@ void MathMacro::draw(PainterInfo & pi, i
h += max(c.descent(), ldim.des) + 5;
}
} else {
+ // FIXME: hack to get position cache of argument cells warm
+ static NullPainter nop;
+ PainterInfo pinop(pi);
+ pinop.pain = nop;
+ for (idx_type i = 0; i < nargs(); ++i)
+ cell(i).draw(pinop, x, y);
+
expanded_.draw(pi, x, y);
}
drawMarkers2(pi, x, y);