Commit cd02553f authored by Boudewijn Rempt's avatar Boudewijn Rempt Committed by Wolthera van Hövell

Make KoStopGradient::colorAt threadsave

Sneakily, the "buffer" variable was made a class variable. Marking
it mutable allows us to change it from a const function, which hides
the fact that this is global data (doubly hidden by there not being
an m_ prefix), which makes the const function thread unsafe.
parent 904cc82d
...@@ -132,6 +132,8 @@ QGradient* KoStopGradient::toQGradient() const ...@@ -132,6 +132,8 @@ QGradient* KoStopGradient::toQGradient() const
void KoStopGradient::colorAt(KoColor& dst, qreal t) const void KoStopGradient::colorAt(KoColor& dst, qreal t) const
{ {
KoColor buffer;
if (! m_stops.count()) if (! m_stops.count())
return; return;
if (t <= m_stops.first().first || m_stops.count() == 1) { if (t <= m_stops.first().first || m_stops.count() == 1) {
...@@ -162,7 +164,7 @@ void KoStopGradient::colorAt(KoColor& dst, qreal t) const ...@@ -162,7 +164,7 @@ void KoStopGradient::colorAt(KoColor& dst, qreal t) const
const KoGradientStop& leftStop = *(stop - 1); const KoGradientStop& leftStop = *(stop - 1);
const KoGradientStop& rightStop = *(stop); const KoGradientStop& rightStop = *(stop);
KoColor startDummy, endDummy; KoColor startDummy, endDummy;
if (mixSpace){ if (mixSpace){
startDummy = KoColor(leftStop.second, mixSpace); startDummy = KoColor(leftStop.second, mixSpace);
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
/// Creates KoStopGradient from a QGradient /// Creates KoStopGradient from a QGradient
static KoStopGradient * fromQGradient(QGradient * gradient); static KoStopGradient * fromQGradient(QGradient * gradient);
/// Sets the gradient stops /// Sets the gradient stops
void setStops(QList<KoGradientStop> stops); void setStops(QList<KoGradientStop> stops);
QList<KoGradientStop> stops() const; QList<KoGradientStop> stops() const;
...@@ -69,10 +69,6 @@ protected: ...@@ -69,10 +69,6 @@ protected:
QPointF m_stop; QPointF m_stop;
QPointF m_focalPoint; QPointF m_focalPoint;
private:
mutable KoColor buffer;
private: private:
void loadKarbonGradient(QIODevice *file); void loadKarbonGradient(QIODevice *file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment