Am Mittwoch, 21. Februar 2007 18:07 schrieb Bo Peng: > 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.
Sorry, I obviously forgot to check whether table selections can be handled when I added the call of 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. This fix does not make sense. The only reason for calling copySelectionToStack in tables was to get the selection to the system clipboard not only as plaintext, but also in LyX format. If that does not work it is better to remove this call and directly copy the plaintext version of the selection to the system clipboard in InsetTabular instead. What copySelection puts in the cut stack is ignored for tables anyway. > I have one question though: Is cur.selBegin().idx() != > cur.selEnd().idx() enough to judge if a cursor has cell selection? Yes. > This is copied from tablemode(cur) in insettablular.C but maybe idx() > is used by some other inset. Only in math, but since your code is only called when the cursor is not in math it works. > I will apply the patch if I get a positive answer for the question. Please don't, the attached patch is better. The only problem we now have is that (due to the qt bug of a lying qApp->clipboard()->ownsClipboard()) table mode copy/paste does not work anymore on the Mac. That means that we either need to find a fix for this bug, or a different workaround for it, or we need to introduce the unified grid cut stack. What shall we do? Georg
Index: src/insets/insettabular.C =================================================================== --- src/insets/insettabular.C (Revision 17292) +++ src/insets/insettabular.C (Arbeitskopie) @@ -1830,13 +1830,13 @@ bool InsetTabular::copySelection(LCursor odocstringstream os; OutputParams const runparams; paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t'); - // Needed for the "Edit->Paste recent" menu and the system clipboard. - cap::copySelection(cur, os.str()); + // FIXME: We should also put the contents in LyX format to the system + // clipboard. + theClipboard().put(string(), os.str()); // mark tabular stack dirty // FIXME: this is a workaround for bug 1919. Should be removed for 1.5, // when we (hopefully) have a one-for-all paste mechanism. - // This must be called after cap::copySelection. dirtyTabularStack(true); return true;
