]> git.lyx.org Git - features.git/commitdiff
Fix bug #7050: Assert when using DecimalAlignment in tables.
authorVincent van Ravesteijn <vfr@lyx.org>
Mon, 3 Jan 2011 14:12:53 +0000 (14:12 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Mon, 3 Jan 2011 14:12:53 +0000 (14:12 +0000)
The problem is/was that when copying an InsetTableCell?, the macrocontext_position_ and the buffer_ were not copied. That's why in InsetTabular?@splitCell@521 and in InsetTabular::TeXRow() and in InsetTabular::metrics we manually copy this into the new object.

However, splitCell() returns the object by-value. So, when we call

InsetTableCell tail = splitCell(head, column_info[c].decimal_point, hassep);

the new object is copied into tail and we lose the buffer_ and macro_contextposition. Later we will crash.

What does *nix in this case ? Apparently they don't make buffer and/or macro_contextposition 0.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37072 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetTabular.cpp

index eff906305729498d525d82d3bc0c6697db0a0bd9..c7bdc768f9987e3bc910d51643b3163d2808759c 100644 (file)
@@ -518,9 +518,6 @@ string const featureAsString(Tabular::Feature action)
 InsetTableCell splitCell(InsetTableCell & head, docstring const align_d, bool & hassep)
 {
        InsetTableCell tail = InsetTableCell(head);
-       tail.getText(0)->setMacrocontextPosition(
-               head.getText(0)->macrocontextPosition());
-       tail.setBuffer(head.buffer());
 
        DocIterator dit = doc_iterator_begin(&head.buffer(), &head);
        for (; dit; dit.forwardChar())
@@ -2524,6 +2521,9 @@ int Tabular::TeXRow(odocstream & os, row_type row,
                        head.setBuffer(buffer());
                        bool hassep = false;
                        InsetTableCell tail = splitCell(head, column_info[c].decimal_point, hassep);
+                       tail.getText(0)->setMacrocontextPosition(
+                               head.getText(0)->macrocontextPosition());
+                       tail.setBuffer(head.buffer());
                        head.latex(os, newrp);
                        os << '&';
                        ret += tail.latex(os, newrp);
@@ -3437,6 +3437,9 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
                                bool hassep = false;
                                InsetTableCell tail = 
                                        splitCell(head, tabular.column_info[c].decimal_point, hassep);
+                               tail.getText(0)->setMacrocontextPosition(
+                                       head.getText(0)->macrocontextPosition());
+                               tail.setBuffer(head.buffer());
                                Dimension dim1;
                                head.metrics(m, dim1);
                                decimal_hoffset = dim1.width();