Dear all, Bug 3238 (reverse table selection + copy crashes lyx) actually has nothing to do with reverse table selection. Cell selection in any direction can trigger the crash. The reason is that copySelectionToStack can not handle cell selection, which is put to special table selection buffer by InsetTablue::copySelection.
The attached patch temporarily fix the crash by bypassing copySelectionToStack for cell selection. I actually put the plain text version of the cell selection to the clipboard so that cells can be pasted somewhere else in plaintext form. The ultimate solution should be the merge of two selection buffers, but this has to wait. I have one question though: Is cur.selBegin().idx() != cur.selEnd().idx() enough to judge if a cursor has cell selection? This is copied from tablemode(cur) in insettablular.C but maybe idx() is used by some other inset. I will apply the patch if I get a positive answer for the question. Cheers, Bo
Index: src/CutAndPaste.C =================================================================== --- src/CutAndPaste.C (revision 17291) +++ src/CutAndPaste.C (working copy) @@ -642,7 +642,20 @@ void copySelection(LCursor & cur, docstring const & plaintext) { - copySelectionToStack(cur, theCuts); + // In tablemode, because copy and paste actually use special table stack + // we do not attemp to get selected paragraphs under cursor. Instead, a + // paragraph with the plain text version is generated so that table cells + // can be pasted as pure text somewhere else. + if (cur.selBegin().idx() != cur.selEnd().idx()) { + ParagraphList pars; + Paragraph par; + BufferParams const & bp = cur.buffer().params(); + par.layout(bp.getLyXTextClass().defaultLayout()); + par.insert(0, plaintext, LyXFont(), Change(Change::UNCHANGED)); + pars.push_back(par); + theCuts.push(make_pair(pars, bp.textclass)); + } else + copySelectionToStack(cur, theCuts); // stuff the selection onto the X clipboard, from an explicit copy request putClipboard(theCuts[0].first, theCuts[0].second, plaintext);