>>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:

Juergen> Jean-Marc Lasgouttes wrote:
>> 2662            in normal use I clicked on a float and lyx crashed
>> 
>>   I think this is fixed by boost upgrade, shall I postpone to
>> 1.4.x?

Juergen> Yes. BTW did you have a look at my patch for bug 2382? Would
Juergen> be a candidate. But it's no showstopper, of course.

I like the patch a lot (removes ad-hoc code). Small nits:

  +     if (&cur.inset() && cur.inset().forceDefaultParagraphs(cur.idx())) {

You do not have to test for &cur.inset(), which is always true.


                  boost::tie(ppp, endpit) =
  -                     pasteSelectionHelper(cur.buffer(),
  +                     pasteSelectionHelper(cur,
                                                text->paragraphs(),
  -                                             cur.pit(), cur.pos(),
                                                parlist, textclass,
                                                el);

Can't you remove the second, third and fourth arguments of
pasteSelectionHelper and get them from cur instead?

I'd like more testing but I won't have time. I attach the patch for
reference.

JMarc

Index: src/insets/insetert.C
===================================================================
--- src/insets/insetert.C	(Revision 14972)
+++ src/insets/insetert.C	(Arbeitskopie)
@@ -255,7 +255,6 @@ void InsetERT::doDispatch(LCursor & cur,
 		ParagraphList::iterator const end = paragraphs().end();
 		for (ParagraphList::iterator par = paragraphs().begin();
 		     par != end; ++par) {
-			par->layout(layout);
 			// in case par had a manual label
 			par->setBeginOfBody();
 			pos_type const siz = par->size();
Index: src/insets/insetcharstyle.C
===================================================================
--- src/insets/insetcharstyle.C	(Revision 14972)
+++ src/insets/insetcharstyle.C	(Arbeitskopie)
@@ -229,27 +229,16 @@ void InsetCharStyle::doDispatch(LCursor 
 {
 	setInlined();
 	switch (cmd.action) {
-		case LFUN_MOUSE_PRESS:
+	
+	case LFUN_MOUSE_PRESS:
 			if (cmd.button() == mouse_button::button3)
 				has_label_ = !has_label_;
 			else
 				InsetText::doDispatch(cur, cmd);
 			break;
-	case LFUN_PASTE:
-	case LFUN_PASTESELECTION: {
+	default:
 		InsetCollapsable::doDispatch(cur, cmd);
-		BufferParams const & bp = cur.buffer().params();
-		LyXLayout_ptr const layout =
-			bp.getLyXTextClass().defaultLayout();
-		ParagraphList::iterator const end = paragraphs().end();
-		for (ParagraphList::iterator par = paragraphs().begin(); 
-				par != end; ++par)
-			par->layout(layout);
 		break;
-		}
-		default:
-			InsetCollapsable::doDispatch(cur, cmd);
-			break;
 	}
 }
 
Index: src/CutAndPaste.C
===================================================================
--- src/CutAndPaste.C	(Revision 14972)
+++ src/CutAndPaste.C	(Arbeitskopie)
@@ -116,11 +116,14 @@ bool checkPastePossible(int index)
 
 
 pair<PitPosPair, pit_type>
-pasteSelectionHelper(Buffer const & buffer, 
-		     ParagraphList & pars, pit_type pit, int pos,
-		     ParagraphList const & parlist, textclass_type textclass, 
+pasteSelectionHelper(LCursor & cur, ParagraphList & pars,
+		     ParagraphList const & parlist, textclass_type textclass,
 		     ErrorList & errorlist)
 {
+	Buffer const & buffer = cur.buffer();
+	pit_type pit = cur.pit();
+	pos_type pos = cur.pos();
+
 	if (parlist.empty())
 		return make_pair(PitPosPair(pit, pos), pit);
 
@@ -149,6 +152,19 @@ pasteSelectionHelper(Buffer const & buff
 		}
 	}
 
+	// If we are in an inset which returns forceDefaultParagraphs,
+	// set the paragraphs to default
+	// FIXME: pars[pit].forceDefaultParagraphs() should be enough,
+	// but returns the wrong values for tabular cells!
+	if (&cur.inset() && cur.inset().forceDefaultParagraphs(cur.idx())) {
+		LyXLayout_ptr const layout = 
+			buffer.params().getLyXTextClass().defaultLayout();
+		ParagraphList::iterator const end = insertion.end();
+		for (ParagraphList::iterator par = insertion.begin(); 
+				par != end; ++par)
+			par->layout(layout);
+	}
+
 	// Make sure there is no class difference.
 	InsetText in;
 	// This works without copying any paragraph data because we have
@@ -617,9 +633,8 @@ void pasteParagraphList(LCursor & cur, P
 		ErrorList el;
 
 		boost::tie(ppp, endpit) =
-			pasteSelectionHelper(cur.buffer(),
+			pasteSelectionHelper(cur,
                                              text->paragraphs(),
-                                             cur.pit(), cur.pos(),
                                              parlist, textclass,
                                              el);
 		bufferErrors(cur.buffer(), el);

Reply via email to