From a7ab2a60adf4ec9e3f31aa35b9019b3544b5d506 Mon Sep 17 00:00:00 2001 From: Jakob Gahde Date: Fri, 24 Nov 2023 21:46:51 +0100 Subject: [PATCH] Fix compiler warnings --- core_lib/src/external/macosx/macosx.cpp | 2 ++ core_lib/src/graphics/bitmap/tiledbuffer.h | 4 ++++ core_lib/src/managers/viewmanager.cpp | 7 ++++--- core_lib/src/tool/cameratool.cpp | 4 ++-- core_lib/src/tool/strokemanager.cpp | 5 ++--- core_lib/src/util/util.cpp | 18 +++++++++--------- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/core_lib/src/external/macosx/macosx.cpp b/core_lib/src/external/macosx/macosx.cpp index deb1316bc9..a4f1f54355 100644 --- a/core_lib/src/external/macosx/macosx.cpp +++ b/core_lib/src/external/macosx/macosx.cpp @@ -39,7 +39,9 @@ namespace PlatformHandler void initialise() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif } } diff --git a/core_lib/src/graphics/bitmap/tiledbuffer.h b/core_lib/src/graphics/bitmap/tiledbuffer.h index 7439c628cd..3e29cfed82 100644 --- a/core_lib/src/graphics/bitmap/tiledbuffer.h +++ b/core_lib/src/graphics/bitmap/tiledbuffer.h @@ -30,7 +30,11 @@ struct TileIndex { int y; }; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) inline uint qHash(const TileIndex &key, uint seed) +#else +inline size_t qHash(const TileIndex &key, size_t seed) +#endif { return qHash(key.x, seed) ^ key.y; } diff --git a/core_lib/src/managers/viewmanager.cpp b/core_lib/src/managers/viewmanager.cpp index 928d11d180..9b85848ea8 100644 --- a/core_lib/src/managers/viewmanager.cpp +++ b/core_lib/src/managers/viewmanager.cpp @@ -205,11 +205,12 @@ void ViewManager::scaleUp() void ViewManager::scaleDown() { - for (size_t i = gZoomLevels.size() - 1; i >= 0; --i) + const size_t nZoomLevels = gZoomLevels.size(); + for (size_t i = 1; i <= nZoomLevels; i++) { - if (mScaling > gZoomLevels[i]) + if (mScaling > gZoomLevels[nZoomLevels - i]) { - scale(gZoomLevels[i]); + scale(gZoomLevels[nZoomLevels - i]); return; } } diff --git a/core_lib/src/tool/cameratool.cpp b/core_lib/src/tool/cameratool.cpp index 9c74fe31a3..e82edb4879 100644 --- a/core_lib/src/tool/cameratool.cpp +++ b/core_lib/src/tool/cameratool.cpp @@ -566,9 +566,9 @@ void CameraTool::paintInterpolations(QPainter& painter, const QTransform& worldT painter.save(); QColor color = cameraDotColor; if (currentFrame > frame && currentFrame < nextFrame) - color.setAlphaF(0.5); + color.setAlphaF(.5f); else - color.setAlphaF(0.2); + color.setAlphaF(.2f); painter.setPen(Qt::black); painter.setBrush(color); diff --git a/core_lib/src/tool/strokemanager.cpp b/core_lib/src/tool/strokemanager.cpp index b4e9a6b4f1..d94ba58b1c 100644 --- a/core_lib/src/tool/strokemanager.cpp +++ b/core_lib/src/tool/strokemanager.cpp @@ -179,7 +179,7 @@ QPointF StrokeManager::interpolateStart(QPointF firstPoint) // Clear queue strokeQueue.clear(); pressureQueue.clear(); - + const int sampleSize = 5; Q_ASSERT(sampleSize > 0); @@ -334,8 +334,7 @@ QList StrokeManager::meanInpolOp(QList points, qreal x, qreal pressure /= strokeQueue.size(); // Use our interpolated points - QPointF mNewInterpolated = mLastInterpolated; - mNewInterpolated = QPointF(x, y); + QPointF mNewInterpolated(x, y); points << mLastPixel << mLastInterpolated << mNewInterpolated << mCurrentPixel; diff --git a/core_lib/src/util/util.cpp b/core_lib/src/util/util.cpp index 39468c04ee..622fb4e44b 100644 --- a/core_lib/src/util/util.cpp +++ b/core_lib/src/util/util.cpp @@ -19,7 +19,7 @@ GNU General Public License for more details. #include #include -static inline bool clipInfiniteLineToEdge(qreal& t0, qreal& t1, qreal p, qreal q) +static inline bool clipLineToEdge(qreal& t0, qreal& t1, qreal p, qreal q) { if (p < 0) { // Line entering the clipping window t0 = qMax(t0, q / p); @@ -37,14 +37,14 @@ QLineF clipLine(const QLineF& line, const QRect& clip, qreal t0, qreal t1) int left = clip.left(), right = left + clip.width(), top = clip.top(), bottom = top + clip.height(); qreal x1 = line.x1(), x2 = line.x2(), dx = line.dx(), y1 = line.y1(), y2 = line.y2(), dy = line.dy(); - if (t0 == 0 && t1 == 1 && (x1 < left && x2 < left || - x1 > right && x2 > right || - y1 < top && y2 < top || - y1 > bottom && y2 > bottom) || - !clipInfiniteLineToEdge(t0, t1, -dx, x1 - left) || - !clipInfiniteLineToEdge(t0, t1, dx, right - x1) || - !clipInfiniteLineToEdge(t0, t1, -dy, y1 - top) || - !clipInfiniteLineToEdge(t0, t1, dy, bottom - y1)) { + if ((t0 == 0 && t1 == 1 && ((x1 < left && x2 < left) || + (x1 > right && x2 > right) || + (y1 < top && y2 < top) || + (y1 > bottom && y2 > bottom))) || + !clipLineToEdge(t0, t1, -dx, x1 - left) || + !clipLineToEdge(t0, t1, dx, right - x1) || + !clipLineToEdge(t0, t1, -dy, y1 - top) || + !clipLineToEdge(t0, t1, dy, bottom - y1)) { return {}; }