This patch fixes that, and bug 2485: text is pasted twice, into formula and into text.
The first part of the patch fixes 2485. I don't see while middle-mouse insertion of the selection (clipboard) should be done both for mouse press and for mouse release... just deleted the first. (There may be reasons I don't know about; please shout.) The second part fixes the crash. The problem is the following. When clicking on a math inset, the click is dispatched to the inset iff the coordinates of the click are inside the inset rectangle. However, when clicking middle mouse into a nestinset, the following stanza is called: if (cmd.button() == mouse_button::button2) { MathArray ar; asArray(cur.bv().getClipboard(), ar); cur.clearSelection(); cur.setScreenPos(cmd.x, cmd.y); cur.insert(ar); cur.bv().update(); return; } Note especially setScreenPos, which redefines the cursor. Tracing this call, we see that ultimately cur.bruteFind() is being called. This returns the cursor positioned in the pit/pos-style document position which is closest (Pythagoras) to the click point. Note the two different ways of deciding whether a click point (x,y) has hit a mathinset: 1) it is within the rectangle representing the mathinset area 2) it is closest to a pit/pos position in the Pythagoras sense, that happens to be inside the mathinset. Especially when clicking inside a mathinset but close to the edge, the two may disagree. And that leads to the assert of dociterator.C:236. A long story, but necessary to explain why the rather lame duct-tape fix ;-) - Martin
Index: math_nestinset.C =================================================================== --- math_nestinset.C (revision 13567) +++ math_nestinset.C (working copy) @@ -1038,10 +1038,6 @@ void MathNestInset::lfunMousePress(LCurs //lyxerr << "## lfunMousePress: setting cursor to: " << cur << endl; cur.bv().mouseSetCursor(cur); } - - if (cmd.button() == mouse_button::button2) { - cur.dispatch(FuncRequest(LFUN_PASTESELECTION)); - } } @@ -1076,8 +1072,11 @@ void MathNestInset::lfunMouseRelease(LCu MathArray ar; asArray(cur.bv().getClipboard(), ar); cur.clearSelection(); + // This calls bruteFind() and may produce a cursor outside mathed... cur.setScreenPos(cmd.x, cmd.y); - cur.insert(ar); + // ...therefore play safe: + if (cur.inMathed()) + cur.insert(ar); cur.bv().update(); return; }
pgpptGV3OX4Pc.pgp
Description: PGP signature