summaryrefslogtreecommitdiffhomepage
path: root/spline-widget
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-03-22 03:37:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2017-03-22 03:37:47 +0100
commit6974ae10b3942eab5cda4b64606af29127d63a0f (patch)
treebc688cda3274377a8d79579c7308c2b5913ee927 /spline-widget
parent543ccb3c5a992dafddb9094481083814c3e342cd (diff)
[COVERITY] spline-widget: fix redundant null check
Diffstat (limited to 'spline-widget')
-rw-r--r--spline-widget/spline-widget.cpp45
1 files changed, 21 insertions, 24 deletions
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());
}
}
}