From 052e9071e9cd3e31d93c1a0c34037aaa5ba9bb71 Mon Sep 17 00:00:00 2001 From: Alfredo Braunstein Date: Sun, 2 Sep 2007 18:05:37 +0000 Subject: [PATCH] fix crash + shut up warning git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20011 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/TextMetrics.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 06982eab97..22d3f4bbcd 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -155,7 +155,7 @@ bool TextMetrics::metrics(MetricsInfo & mi, Dimension & dim) Dimension const old_dim = dim_; // reset dimension. dim_ = Dimension(); - size_t npar = text_->paragraphs().size(); + pit_type const npar = text_->paragraphs().size(); if (npar > 1) // If there is more than one row, expand the text to // the full allowable width. @@ -1776,10 +1776,14 @@ void TextMetrics::drawSelection(PainterInfo & pi, int x, int) const || bv_funcs::status(bv_, end) == bv_funcs::CUR_ABOVE) return; - if (beg.pit() < par_metrics_.begin()->first) + if (beg.pit() < par_metrics_.begin()->first) { beg.pit() = par_metrics_.begin()->first; - if (end.pit() > par_metrics_.rbegin()->first) + beg.pos() = 0; + } + if (end.pit() > par_metrics_.rbegin()->first) { end.pit() = par_metrics_.rbegin()->first; + end.pos() = end.lastpos(); + } ParagraphMetrics const & pm1 = par_metrics_[beg.pit()]; ParagraphMetrics const & pm2 = par_metrics_[end.pit()];