summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-10-26 06:52:47 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-10-26 06:55:34 +0200
commitdb0d7e4ca4288e189a65e1c8e38d196dace0a315 (patch)
tree9c76c4d5c8f89c82c171cc2fd5c04e65c33c7fae
parent9c4e1586334b2e978d3993c97031d79f079f9650 (diff)
spline-widget: use stable sort
-rw-r--r--spline-widget/spline.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/spline-widget/spline.cpp b/spline-widget/spline.cpp
index 125b266d..1bd57f89 100644
--- a/spline-widget/spline.cpp
+++ b/spline-widget/spline.cpp
@@ -151,7 +151,7 @@ QPointF spline::ensure_in_bounds(const QList<QPointF>& points, int i)
bool spline::sort_fn(const QPointF& one, const QPointF& two)
{
- return one.x() < two.x();
+ return one.x() <= two.x();
}
void spline::update_interp_data()
@@ -161,7 +161,7 @@ void spline::update_interp_data()
if (points.size() == 0)
points.append(QPointF(max_x, max_y));
- std::sort(points.begin(), points.end(), sort_fn);
+ std::stable_sort(points.begin(), points.end(), sort_fn);
const double mult = precision(points);
const double mult_ = mult * 30;
@@ -251,7 +251,7 @@ void spline::addPoint(QPointF pt)
points_t points = s->points;
points.push_back(pt);
- std::sort(points.begin(), points.end(), sort_fn);
+ std::stable_sort(points.begin(), points.end(), sort_fn);
s->points = points;
update_interp_data();
}
@@ -266,7 +266,7 @@ void spline::movePoint(int idx, QPointF pt)
{
points[idx] = pt;
// we don't allow points to be reordered, but sort due to possible caller logic error
- std::sort(points.begin(), points.end(), sort_fn);
+ std::stable_sort(points.begin(), points.end(), sort_fn);
s->points = points;
update_interp_data();
}
@@ -345,7 +345,7 @@ void spline::recompute()
// storing to s->points fires bundle::changed and that leads to an infinite loop
// only store if we can't help it
- std::sort(list.begin(), list.end(), sort_fn);
+ std::stable_sort(list.begin(), list.end(), sort_fn);
if (list != s->points)
{