From 3830ce46db8b32003728b792e8b7c8e6c6d55561 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 14 Jan 2015 11:49:05 +0100 Subject: [PATCH] Squash warnings reported by gcc 4.9 Most of these are just about conversion from double to int. Of note also the replacement of an horrible reinterpret_cast by a proper solution. --- src/ParagraphMetrics.cpp | 3 +-- src/frontends/qt4/CategorizedCombo.cpp | 2 +- src/frontends/qt4/GuiFontMetrics.cpp | 4 ++-- src/frontends/qt4/GuiPainter.cpp | 3 ++- src/frontends/qt4/GuiView.cpp | 10 +++++----- src/frontends/qt4/GuiWorkArea_Private.h | 11 +++++++---- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp index 0e37c5f5d9..77e126eed2 100644 --- a/src/ParagraphMetrics.cpp +++ b/src/ParagraphMetrics.cpp @@ -105,10 +105,9 @@ size_t ParagraphMetrics::computeRowSignature(Row const & row, static_cast(row.sel_end), row.begin_margin_sel, row.end_margin_sel, - reinterpret_cast(&row.separator)[0], - reinterpret_cast(&row.separator)[1], d.wid, d.asc, d.des }; crc.process_bytes(b, sizeof(b)); + crc.process_bytes(&row.separator, sizeof(row.separator)); return crc.checksum(); } diff --git a/src/frontends/qt4/CategorizedCombo.cpp b/src/frontends/qt4/CategorizedCombo.cpp index b380a4c561..b52172d950 100644 --- a/src/frontends/qt4/CategorizedCombo.cpp +++ b/src/frontends/qt4/CategorizedCombo.cpp @@ -245,7 +245,7 @@ void CCItemDelegate::drawCategoryHeader(QPainter * painter, QStyleOptionViewItem QFontMetrics fm(font); int w = fm.width(category); int x = opt.rect.x() + (opt.rect.width() - w) / 2; - int y = opt.rect.y() + 1.5 * fm.ascent(); + int y = opt.rect.y() + 3 * fm.ascent() / 2; int left = x; int right = x + w; painter->drawText(x, y, category); diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp index 6952e964ec..f3a4c0fab7 100644 --- a/src/frontends/qt4/GuiFontMetrics.cpp +++ b/src/frontends/qt4/GuiFontMetrics.cpp @@ -162,7 +162,7 @@ int GuiFontMetrics::pos2x(docstring const & s, int const pos, bool const rtl) co { QTextLayout tl; setTextLayout(tl, s, font_, rtl); - return tl.lineForTextPosition(pos).cursorToX(pos); + return static_cast(tl.lineForTextPosition(pos).cursorToX(pos)); } @@ -172,7 +172,7 @@ int GuiFontMetrics::x2pos(docstring const & s, int & x, bool const rtl) const setTextLayout(tl, s, font_, rtl); int pos = tl.lineForTextPosition(0).xToCursor(x); // correct x value to the actual cursor position. - x = tl.lineForTextPosition(0).cursorToX(pos); + x = static_cast(tl.lineForTextPosition(0).cursorToX(pos)); return pos; } diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index 5718fbb60a..de1ca71d2b 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -380,7 +380,8 @@ int GuiPainter::text(int x, int y, docstring const & s, int const mD = fm.maxDescent(); int const h = mA + mD; if (w > 0 && h > 0) { - pm = QPixmap(pixelRatio() * w , pixelRatio() * h); + pm = QPixmap(static_cast(pixelRatio() * w), + static_cast(pixelRatio() * h)); #if QT_VERSION >= 0x050000 pm.setDevicePixelRatio(pixelRatio()); #endif diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 5ddcdb4741..1fbe8256eb 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -162,9 +162,9 @@ public: QPainter pain(&splash_); pain.setPen(QColor(0, 0, 0)); double const multiplier = splashPixelRatio() / pixelRatio(); - int const size = toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble() * multiplier; - int const x = 190 * multiplier; - int const y = 225 * multiplier; + int const size = static_cast(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble() * multiplier); + int const x = static_cast(190 * multiplier); + int const y = static_cast(225 * multiplier); LYXERR(Debug::GUI, "widget pixel ratio: " << pixelRatio() << " splash pixel ratio: " << splashPixelRatio() << @@ -181,8 +181,8 @@ public: void paintEvent(QPaintEvent *) { - int const w = splash_.width() / splashPixelRatio(); - int const h = splash_.height() / splashPixelRatio(); + int const w = static_cast(splash_.width() / splashPixelRatio()); + int const h = static_cast(splash_.height() / splashPixelRatio()); int const x = (width() - w) / 2; int const y = (height() - h) / 2; LYXERR(Debug::GUI, diff --git a/src/frontends/qt4/GuiWorkArea_Private.h b/src/frontends/qt4/GuiWorkArea_Private.h index cdf054bc91..5320c5c713 100644 --- a/src/frontends/qt4/GuiWorkArea_Private.h +++ b/src/frontends/qt4/GuiWorkArea_Private.h @@ -126,15 +126,18 @@ struct GuiWorkArea::Private delete screen_; pixel_ratio_ = p->pixelRatio(); if (lyxrc.use_qimage) { - QImage *x = new QImage(pixel_ratio_ * p->viewport()->width(), - pixel_ratio_ * p->viewport()->height(), QImage::Format_ARGB32_Premultiplied); + QImage *x = + new QImage(static_cast(pixel_ratio_ * p->viewport()->width()), + static_cast(pixel_ratio_ * p->viewport()->height()), + QImage::Format_ARGB32_Premultiplied); #if QT_VERSION >= 0x050000 x->setDevicePixelRatio(pixel_ratio_); #endif screen_ = x; } else { - QPixmap *x = new QPixmap(pixel_ratio_ * p->viewport()->width(), - pixel_ratio_ * p->viewport()->height()); + QPixmap *x = + new QPixmap(static_cast(pixel_ratio_ * p->viewport()->width()), + static_cast(pixel_ratio_ * p->viewport()->height())); #if QT_VERSION >= 0x050000 x->setDevicePixelRatio(pixel_ratio_); #endif