Author: spitz
Date: Sat Jan 21 18:16:56 2012
New Revision: 40644
URL: http://www.lyx.org/trac/changeset/40644

Log:
Fix crash when putting a float around multiple display maths (bug #7974).

Modified:
   lyx-devel/branches/BRANCH_2_0_X/src/Text3.cpp
   lyx-devel/branches/BRANCH_2_0_X/status.20x

Modified: lyx-devel/branches/BRANCH_2_0_X/src/Text3.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/Text3.cpp       Sat Jan 21 13:17:39 
2012        (r40643)
+++ lyx-devel/branches/BRANCH_2_0_X/src/Text3.cpp       Sat Jan 21 18:16:56 
2012        (r40644)
@@ -1648,16 +1648,19 @@
        case LFUN_FLOAT_INSERT:
        case LFUN_FLOAT_WIDE_INSERT:
        case LFUN_WRAP_INSERT: {
-               // will some text be moved into the inset?
-               bool content = cur.selection();
+               // will some content be moved into the inset?
+               bool const content = cur.selection();
+               // does the content consist of multiple paragraphs?
+               bool const singlepar = (cur.selBegin().pit() == 
cur.selEnd().pit());
 
                doInsertInset(cur, this, cmd, true, true);
                cur.posForward();
 
-               // If some text is moved into the inset, doInsertInset 
-               // puts the cursor outside the inset. To insert the
-               // caption we put it back into the inset.
-               if (content)
+               // If some single-par content is moved into the inset,
+               // doInsertInset puts the cursor outside the inset.
+               // To insert the caption we put it back into the inset.
+               // FIXME cleanup doInsertInset to avoid such dances!
+               if (content && singlepar)
                        cur.backwardPos();
 
                ParagraphList & pars = cur.text()->paragraphs();

Modified: lyx-devel/branches/BRANCH_2_0_X/status.20x
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/status.20x  Sat Jan 21 13:17:39 2012        
(r40643)
+++ lyx-devel/branches/BRANCH_2_0_X/status.20x  Sat Jan 21 18:16:56 2012        
(r40644)
@@ -174,6 +174,8 @@
 - Fix crash when performing "forward search" while cursor is in mathed
   (bug 7992).
 
+- Fix crash when inserting a float around multiple display maths (bug 7974).
+
 - Update citation labels when the BibTeX file changes (bug 7499).
 
 - Mark Buffer dirty when changing branch activation status (bug 7872). Sadly,

Reply via email to