From 6974ae10b3942eab5cda4b64606af29127d63a0f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 22 Mar 2017 03:37:47 +0100 Subject: [COVERITY] spline-widget: fix redundant null check --- spline-widget/spline-widget.cpp | 45 +++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'spline-widget') diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp index 5fa0644c..c7dd5e5a 100644 --- a/spline-widget/spline-widget.cpp +++ b/spline-widget/spline-widget.cpp @@ -324,38 +324,35 @@ void spline_widget::mousePressEvent(QMouseEvent *e) { bool bTouchingPoint = false; moving_control_point_idx = -1; - if (_config) + for (int i = 0; i < points.size(); i++) + { + if (point_within_pixel(points[i], e->pos())) + { + bTouchingPoint = true; + moving_control_point_idx = int(i); + break; + } + } + if (!bTouchingPoint) { + bool too_close = false; + const QPoint pos = e->pos(); + for (int i = 0; i < points.size(); i++) { - if (point_within_pixel(points[i], e->pos())) + const QPointF pt = point_to_pixel(points[i]); + const qreal x = std::fabs(pt.x() - pos.x()); + if (point_pixel_closeness_limit >= x) { - bTouchingPoint = true; - moving_control_point_idx = int(i); + too_close = true; break; } } - if (!bTouchingPoint) - { - bool too_close = false; - const QPoint pos = e->pos(); - - for (int i = 0; i < points.size(); i++) - { - const QPointF pt = point_to_pixel(points[i]); - const qreal x = std::fabs(pt.x() - pos.x()); - if (point_pixel_closeness_limit >= x) - { - too_close = true; - break; - } - } - if (!too_close) - { - _config->add_point(pixel_coord_to_point(e->pos())); - show_tooltip(e->pos()); - } + if (!too_close) + { + _config->add_point(pixel_coord_to_point(e->pos())); + show_tooltip(e->pos()); } } } -- cgit v1.2.3