]> git.lyx.org Git - lyx.git/commitdiff
Avoid swapping a cell with itself
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 23 Dec 2015 10:05:28 +0000 (11:05 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 26 Dec 2015 12:59:25 +0000 (13:59 +0100)
Gcc STL debugging feature asserts when swapping an object with itself. This happens in some cases with math grids that have only one column.

A quick review of other uses of swap() in the code base did not reveal any other dubious case.

Fixes bug #9902.

src/mathed/InsetMathGrid.cpp

index 8ea3940729ddda53882883d05df44807b7b85992..536f4bd163a671347d7a15150f7da6c407a1d4bb 100644 (file)
@@ -1439,7 +1439,8 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
 
                // split cell
                splitCell(cur);
-               swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
+               if (ncols() > 1)
+                       swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
                if (cur.idx() > 0)
                        --cur.idx();
                cur.pos() = cur.lastpos();