Commit 7be37e4a authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix PVS-Studio warning: implicit int->qreal conversions cause precision loss

V601: The bool type is implicitly cast to the integer type
V636: Expression was implicitly cast from 'int' type to 'double' type

CCBUG:393431
parent 6dfd56d2
......@@ -159,6 +159,6 @@ qint64 KoImageDataPrivate::generateKey(const QByteArray &bytes)
qint64 answer = 1;
const int max = qMin(8, bytes.count());
for (int x = 0; x < max; ++x)
answer += bytes[x] << (8 * x);
answer += qint64(bytes[x] << (8 * x));
return answer;
}
......@@ -141,7 +141,7 @@ QPointF KisVisualEllipticalSelectorShape::convertWidgetCoordinateToShapeCoordina
qreal y = 1.0;
qreal offset = 7.0;
QPointF center = QRectF(QPointF(0.0, 0.0), this->size()).center();
qreal a = (this->width()/2);
qreal a = 0.5 * this->width()/2;
qreal xRel = center.x()-coordinate.x();
qreal yRel = center.y()-coordinate.y();
qreal angle = atan2(xRel, yRel);
......
......@@ -98,8 +98,8 @@ QRect KisVisualRectangleSelectorShape::getSpaceForTriangle(QRect geom)
QPointF KisVisualRectangleSelectorShape::convertShapeCoordinateToWidgetCoordinate(QPointF coordinate)
{
qreal x = m_barWidth/2;
qreal y = m_barWidth/2;
qreal x = 0.5 * m_barWidth;
qreal y = 0.5 * m_barWidth;
qreal offset = 5.0;
KisVisualColorSelectorShape::Dimensions dimension = getDimensions();
if (dimension == KisVisualColorSelectorShape::onedimensional) {
......
......@@ -198,7 +198,7 @@ void KisPresetLivePreviewView::setupAndPaintStroke()
double textureScale = settings->getDouble("Texture/Pattern/Scale");
if ( textureOffsetX*textureScale> maxTextureSize || textureOffsetY*textureScale > maxTextureSize) {
int maxSize = qMax(textureOffsetX, textureOffsetY);
double result = maxTextureSize/maxSize;
double result = qreal(maxTextureSize) / maxSize;
settings->setProperty("Texture/Pattern/Scale", result);
}
if (m_currentPreset->paintOp().id() == "spraybrush") {
......
......@@ -61,8 +61,8 @@ void KoPagePreviewWidget::paintEvent(QPaintEvent *event)
const bool pageSpread = (d->pageLayout.bindingSide >= 0 && d->pageLayout.pageEdge >= 0);
qreal sheetWidth = pageWidth / (pageSpread?2:1);
qreal zoomH = (height() * 90 / 100) / pageHeight;
qreal zoomW = (width() * 90 / 100) / pageWidth;
qreal zoomH = (height() * 90.0 / 100.0) / pageHeight;
qreal zoomW = (width() * 90.0 / 100.0) / pageWidth;
qreal zoom = qMin( zoomW, zoomH );
pageWidth *= zoom;
......
......@@ -85,7 +85,7 @@ void RulerTabChooser::paintEvent(QPaintEvent *)
painter.setBrush(palette().color(QPalette::Text));
painter.setRenderHint( QPainter::Antialiasing );
qreal x= width()/2;
qreal x = 0.5 * width();
painter.translate(0,-height()/2+5);
switch (m_type) {
......
......@@ -217,18 +217,19 @@ KoColor KisColorSelectorWheel::colorAt(int x, int y, bool forceValid)
Q_ASSERT(x>=0 && x<=width());
Q_ASSERT(y>=0 && y<=height());
qreal xRel = x-width()/2.;
qreal yRel = y-height()/2.;
const qreal xRel = x - 0.5 * width();
const qreal yRel = y - 0.5 * height();
const qreal minDimension = qMin(width(), height());
qreal radius = sqrt(xRel*xRel+yRel*yRel);
if(radius > qMin(width(), height())/2) {
if (radius > 0.5 * minDimension) {
if (!forceValid) {
return color;
} else {
radius = qMin(width(), height())/2;
radius = 0.5 * minDimension;
}
}
radius /= qMin(width(), height())/2.;
radius /= 0.5 * minDimension;
qreal angle = std::atan2(yRel, xRel);
angle += M_PI;
......
......@@ -133,13 +133,10 @@ qreal EnhancedPathFormula::evaluate()
// lazy evaluation
if (!m_compiled) {
TokenList tokens = scan(m_text);
if (m_error != ErrorNone) {
debugTokens(tokens);
}
if (!compile(tokens)) {
debugOpcodes();
m_error = ErrorCompile;
return false;
return 0.0;
}
m_compiled = true;
}
......
......@@ -422,7 +422,7 @@ bool EnhancedPathShape::useStretchPoints(const QSizeF &size, qreal &scale)
if (m_pathStretchPointX != -1 && m_pathStretchPointY != -1) {
qreal scaleX = size.width();
qreal scaleY = size.height();
if (m_viewBox.width() / m_viewBox.height() < scaleX / scaleY) {
if (qreal(m_viewBox.width()) / m_viewBox.height() < qreal(scaleX) / scaleY) {
qreal deltaX = (scaleX * m_viewBox.height()) / scaleY - m_viewBox.width();
foreach (KoSubpath *subpath, d->subpaths) {
foreach (KoPathPoint *currPoint, *subpath) {
......@@ -439,7 +439,7 @@ bool EnhancedPathShape::useStretchPoints(const QSizeF &size, qreal &scale)
}
}
scale = scaleY / m_viewBox.height();
} else if (m_viewBox.width() / m_viewBox.height() > scaleX / scaleY) {
} else if (qreal(m_viewBox.width()) / m_viewBox.height() > qreal(scaleX) / scaleY) {
qreal deltaY = (m_viewBox.width() * scaleY) / scaleX - m_viewBox.height();
foreach (KoSubpath *subpath, d->subpaths) {
foreach (KoPathPoint *currPoint, *subpath) {
......
......@@ -595,8 +595,8 @@ public:
//initialize field from an existing (possibly smaller) nearest neighbor field
void initialize(const NearestNeighborField& nnf)
{
float xscale = imSize.width() / nnf.imSize.width();
float yscale = imSize.height() / nnf.imSize.height();
float xscale = qreal(imSize.width()) / nnf.imSize.width();
float yscale = qreal(imSize.height()) / nnf.imSize.height();
for (int y = 0; y < imSize.height(); y++) {
for (int x = 0; x < imSize.width(); x++) {
......@@ -977,7 +977,7 @@ QRect patchImage(const KisPaintDeviceSP imageDev, const KisPaintDeviceSP maskDev
QRect maskRect = getMaskBoundingBox(maskDev);
QRect imageRect = imageDev->exactBounds();
float scale = 1 + (accuracy / 25); //higher accuracy means we include more surrounding area around the patch. Minimum 2x padding.
float scale = 1.0 + (accuracy / 25.0); //higher accuracy means we include more surrounding area around the patch. Minimum 2x padding.
int dx = maskRect.width() * scale;
int dy = maskRect.height() * scale;
maskRect.adjust(-dx, -dy, dx, dy);
......
......@@ -163,7 +163,7 @@ void TransformStrokeStrategy::doStrokeCallback(KisStrokeJobData *data)
KisStrokeJobData::NORMAL);
td->node->setDirty(oldExtent | td->node->extent());
} if (KisExternalLayer *extLayer =
} else if (KisExternalLayer *extLayer =
dynamic_cast<KisExternalLayer*>(td->node.data())) {
if (td->config.mode() == ToolTransformArgs::FREE_TRANSFORM ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment