]> git.lyx.org Git - lyx.git/blobdiff - src/Row.cpp
Possible fix for the mystery crash, which is bug #9049.
[lyx.git] / src / Row.cpp
index 1336d05a20bfbeb76f0dabf33b913a29dd64ac98..aeede91d85e7d0e61371eec64cc2edffc56bab5d 100644 (file)
@@ -45,12 +45,12 @@ double Row::Element::pos2x(pos_type const i) const
 
        bool const rtl = font.isVisibleRightToLeft();
 
-       int w = 0;
+       double w = 0;
        //handle first the two bounds of the element
-       if (i == pos || type != STRING)
-               w = rtl ? width() : 0;
-       else if (i == endpos)
+       if (i == endpos && !(inset && inset->lyxCode() == SEPARATOR_CODE))
                w = rtl ? 0 : width();
+       else if (i == pos || type != STRING)
+               w = rtl ? width() : 0;
        else {
                FontMetrics const & fm = theFontMetrics(font);
                w = fm.pos2x(str, i - pos, font.isVisibleRightToLeft());
@@ -70,7 +70,7 @@ pos_type Row::Element::x2pos(double &x) const
        case STRING: {
                FontMetrics const & fm = theFontMetrics(font);
                // FIXME: is it really necessary for x to be a double?
-               int xx = x;
+               int xx = int(x);
                i = fm.x2pos(str, xx, rtl);
                x = xx;
                break;
@@ -113,9 +113,9 @@ bool Row::Element::breakAt(double w)
                return false;
        str = str.substr(0, new_pos - pos);
        if (rtl)
-               dim.wid -= w;
+               dim.wid -= int(w);
        else
-               dim.wid = w;
+               dim.wid = int(w);
        endpos = new_pos;
        return true;
 }
@@ -250,7 +250,8 @@ ostream & operator<<(ostream & os, Row const & row)
           << " ascent: " << row.dim_.asc
           << " descent: " << row.dim_.des
           << " separator: " << row.separator
-          << " label_hfill : " << row.label_hfill << "\n";
+          << " label_hfill: " << row.label_hfill 
+          << " row_boundary: " << row.right_boundary() << "\n";
        double x = row.x;
        Row::Elements::const_iterator it = row.elements_.begin();
        for ( ; it != row.elements_.end() ; ++it) {
@@ -404,7 +405,7 @@ void Row::shortenIfNeeded(pos_type const keep, int const w)
        double max_w = w - x;
        if (first_below->breakAt(max_w)) {
                end_ = first_below->endpos;
-               dim_.wid = x + first_below->width();
+               dim_.wid = int(x + first_below->width());
                // If there are other elements, they should be removed.
                elements_.erase(boost::next(first_below), end);
        } else if (first_below->pos > pos_) {