diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-27 13:36:01 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-05-27 15:39:30 +0200 |
commit | 756c4c9e6d51564bc32c99701efd939303ce31ff (patch) | |
tree | 25e8f4d6e6cd52e636d69777ec8d75acc32e3d9e /examples/quick/scenegraph/graph/noisynode.cpp | |
parent | 201f28c7e332bc0cb37a80f4ffff0d473d24455a (diff) |
Avoid truncating in QSGMaterial::compare() implementations
The Qt 5.0 pattern of subtracting pointers and returning them is not
suitable (on 64-bit archs) since the return type is an int.
There is also QSGTexture::comparisonKey() now which is a qint64.
Just return -1 and 1 as appropriate.
Change-Id: Iaf3377b484a8c4b19b0960f1e8def05e4fa68ce7
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'examples/quick/scenegraph/graph/noisynode.cpp')
-rw-r--r-- | examples/quick/scenegraph/graph/noisynode.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp index e85757d426..c39e775e98 100644 --- a/examples/quick/scenegraph/graph/noisynode.cpp +++ b/examples/quick/scenegraph/graph/noisynode.cpp @@ -107,10 +107,8 @@ public: if (!state.texture || !other->state.texture) return state.texture ? 1 : -1; - if (qint64 diff = state.texture->comparisonKey() - other->state.texture->comparisonKey()) - return diff; - - return 0; + const qint64 diff = state.texture->comparisonKey() - other->state.texture->comparisonKey(); + return diff < 0 ? -1 : (diff > 0 ? 1 : 0); } struct { |