summaryrefslogtreecommitdiffhomepage
path: root/spline/spline.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-20 18:23:14 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-24 19:31:24 +0100
commite81df263f4123a39fe6d4d50fb21f47dd242e796 (patch)
tree4b8cd13da31ac3fb3a2d2695b65595d7c5570439 /spline/spline.cpp
parent2613beb8028ecac53548d311b27ff38559763f6c (diff)
remove const correctness violations
This is possibly related to a livelock where several threads do const removal in their respective code paths. Use the `mutable' specifier for the mutexes and spline's cached data. Now using the `mutable' specifier, get rid of <optional> in compat/mutex.
Diffstat (limited to 'spline/spline.cpp')
-rw-r--r--spline/spline.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 752e85d1..9b0147a8 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -75,11 +75,6 @@ float spline::get_value(double x)
float spline::get_value_no_save(double x) const
{
- return const_cast<spline&>(*this).get_value_no_save_internal(x);
-}
-
-float spline::get_value_no_save_internal(double x)
-{
QMutexLocker foo(&_mutex);
float q = float(x * bucket_size_coefficient(points));
@@ -98,7 +93,7 @@ bool spline::get_last_value(QPointF& point)
return activep;
}
-float spline::get_value_internal(int x)
+float spline::get_value_internal(int x) const
{
if (!validp)
{
@@ -112,12 +107,6 @@ float spline::get_value_internal(int x)
return sign * clamp(ret_, 0, 1000);
}
-void spline::add_lone_point()
-{
- points = { QPointF(s->opts.clamp_x_, s->opts.clamp_y_) };
- s->points = points;
-}
-
QPointF spline::ensure_in_bounds(const QList<QPointF>& points, int i)
{
const int sz = points.size();
@@ -148,7 +137,7 @@ bool spline::sort_fn(const QPointF& one, const QPointF& two)
return one.x() < two.x();
}
-void spline::update_interp_data()
+void spline::update_interp_data() const
{
points_t list = points;
ensure_valid(list);
@@ -208,7 +197,7 @@ void spline::update_interp_data()
};
// multiplier helps fill in all the x's needed
- const unsigned end = int(c_interp * (p2_x - p1_x)) + 1;
+ const unsigned end{int(c_interp * (p2_x - p1_x)) + 1u};
for (unsigned k = 0; k <= end; k++)
{
@@ -363,7 +352,7 @@ double spline::max_output() const
return std::fabs(clamp.to<double>());
}
-void spline::ensure_valid(points_t& list)
+void spline::ensure_valid(points_t& list) const
{
QMutexLocker foo(&_mutex);