1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix: use qAbs() instead of abs() for better platform compatibility

Apparently FreeBSD doesn't include by default `stdlib.h` that provides
`abs()`.

Fix suggested by @antis81.

Fixes #3613.
This commit is contained in:
Zetok Zalbavar 2016-08-12 21:55:45 +01:00
parent f3c77c5cc7
commit 79c249be55
No known key found for this signature in database
GPG Key ID: C953D3880212068A
3 changed files with 5 additions and 7 deletions

View File

@ -63,7 +63,7 @@ bool VideoMode::operator==(const VideoMode &other) const
uint32_t VideoMode::norm(const VideoMode &other) const
{
return abs(this->width-other.width) + abs(this->height-other.height);
return qAbs(this->width-other.width) + qAbs(this->height-other.height);
}
/**

View File

@ -19,8 +19,6 @@
#include "screengrabberchooserrectitem.h"
#include <cstdlib>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene>
#include <QPainter>
@ -213,8 +211,8 @@ void ScreenGrabberChooserRectItem::mouseMoveHandle(int x, int y, QGraphicsSceneM
return;
QPointF delta = event->scenePos() - event->lastScenePos();
delta.rx() *= qreal(std::abs(x));
delta.ry() *= qreal(std::abs(y));
delta.rx() *= qAbs(x);
delta.ry() *= qAbs(y);
// We increase if the multiplier and the delta have the same sign
bool increaseX = ((x < 0) == (delta.x() < 0));

View File

@ -200,8 +200,8 @@ void ScreenshotGrabber::adjustTooltipPosition()
QRect recGL = QGuiApplication::primaryScreen()->virtualGeometry();
QRect rec = qApp->desktop()->screenGeometry(QCursor::pos());
const QRectF ttRect = this->helperToolbox->childrenBoundingRect();
int x = abs(recGL.x()) + rec.x() + ((rec.width() - ttRect.width()) / 2);
int y = abs(recGL.y()) + rec.y();
int x = qAbs(recGL.x()) + rec.x() + ((rec.width() - ttRect.width()) / 2);
int y = qAbs(recGL.y()) + rec.y();
// Multiply by devicePixelRatio to get centered positions under scaling
helperToolbox->setX(x * pixRatio);