The following patch hopefully fixes bug 2630. I say "hopefully"
because I cannot reproduce it myself, and valgrind is mute on the
subject. 

I attach the document on which to reproduce it. Just try to select the
two cells of the table.

What happens is that the selection spans several cells, but the code
for changeDepthAllowed reads

        pit_type const beg = cur.selBegin().pit();
        pit_type const end = cur.selEnd().pit() + 1;
        int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);

        for (pit_type pit = beg; pit != end; ++pit) {
                if (::changeDepthAllowed(type, pars_[pit], max_depth))
                        return true;

As you can see, havoc ensues because beg and end are taken as if they
belonged to the same text inset. The patch just quits early in this
situation. 

People who can reproduce it (Uwe?), please tell me whether it works.
As.gentoo, can you apply the patch and try it out?

JMarc

Index: src/text2.C
===================================================================
--- src/text2.C	(revision 14657)
+++ src/text2.C	(working copy)
@@ -385,6 +385,10 @@
 bool LyXText::changeDepthAllowed(LCursor & cur, DEPTH_CHANGE type) const
 {
 	BOOST_ASSERT(this == cur.text());
+	// this happens when selecting several cells in tabular (bug 2630)
+	if (cur.idx() != cur.anchor().idx())
+		return false;
+
 	pit_type const beg = cur.selBegin().pit();
 	pit_type const end = cur.selEnd().pit() + 1;
 	int max_depth = (beg != 0 ? pars_[beg - 1].getMaxDepthAfter() : 0);

Attachment: bug2630.lyx
Description: Binary data

Reply via email to