From: Jean-Marc Lasgouttes Date: Wed, 23 Dec 2015 10:05:28 +0000 (+0100) Subject: Avoid swapping a cell with itself X-Git-Tag: 2.2.0beta1~310 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=30cf941cb3d1b8edc980fe57908bfcaff2cdca68;p=lyx.git Avoid swapping a cell with itself 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. --- diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp index 8ea3940729..536f4bd163 100644 --- a/src/mathed/InsetMathGrid.cpp +++ b/src/mathed/InsetMathGrid.cpp @@ -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();