]> git.lyx.org Git - features.git/commitdiff
Squash warnings reported by gcc 4.9
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 14 Jan 2015 10:49:05 +0000 (11:49 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 14 Jan 2015 10:52:14 +0000 (11:52 +0100)
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
src/frontends/qt4/CategorizedCombo.cpp
src/frontends/qt4/GuiFontMetrics.cpp
src/frontends/qt4/GuiPainter.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea_Private.h

index 0e37c5f5d9b2e139bba01288b1c83cf0eace2891..77e126eed279caf63b933ba35188589bac45653e 100644 (file)
@@ -105,10 +105,9 @@ size_t ParagraphMetrics::computeRowSignature(Row const & row,
                                static_cast<char_type>(row.sel_end),
                                row.begin_margin_sel,
                                row.end_margin_sel,
-                               reinterpret_cast<char_type const *>(&row.separator)[0],
-                               reinterpret_cast<char_type const *>(&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();
 }
index b380a4c56173f1dccd8eab952053670f27807499..b52172d95099fbfed4d1942c2c761556adf71446 100644 (file)
@@ -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);
index 6952e964ec5a01a81eed0fda01b81a6125e59a18..f3a4c0fab79999a6ea63371e4fb65e0ce1fbd5fc 100644 (file)
@@ -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<int>(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<int>(tl.lineForTextPosition(0).cursorToX(pos));
        return pos;
 }
 
index 5718fbb60aa3a11881b6d457ae8021cf9649b60b..de1ca71d2b53427cc8893190dd3860cc2d7bc6f0 100644 (file)
@@ -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<int>(pixelRatio() * w),
+                                                static_cast<int>(pixelRatio() * h));
 #if QT_VERSION >= 0x050000
                        pm.setDevicePixelRatio(pixelRatio());
 #endif
index 5ddcdb47412564482f0b7cd43daa4d0dda5b6f6a..1fbe8256eb39f9e82325e4fd2a37434a9eadb0e2 100644 (file)
@@ -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<int>(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble() * multiplier);
+               int const x = static_cast<int>(190 * multiplier);
+               int const y = static_cast<int>(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<int>(splash_.width() / splashPixelRatio());
+               int const h = static_cast<int>(splash_.height() / splashPixelRatio());
                int const x = (width() - w) / 2;
                int const y = (height() - h) / 2;
                LYXERR(Debug::GUI,
index cdf054bc9117e6081b6fae65365b5b0b156b7f4a..5320c5c7133ce9faeeaeeb5478049306c2a1355a 100644 (file)
@@ -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<int>(pixel_ratio_ * p->viewport()->width()),
+                                                  static_cast<int>(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<int>(pixel_ratio_ * p->viewport()->width()),
+                                                       static_cast<int>(pixel_ratio_ * p->viewport()->height()));
 #if QT_VERSION >= 0x050000
                        x->setDevicePixelRatio(pixel_ratio_);
 #endif