Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit dddd8c48 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Avoid cycling updates in KoFillConfigWidget

They may cause crashes if update handlers start
enter each other recursively.

BUG:392726
parent 30136e54
......@@ -46,6 +46,18 @@ KoStopGradient::~KoStopGradient()
{
}
bool KoStopGradient::operator==(const KoStopGradient &rhs) const
{
return
*colorSpace() == *rhs.colorSpace() &&
spread() == rhs.spread() &&
type() == rhs.type() &&
m_start == rhs.m_start &&
m_stop == rhs.m_stop &&
m_focalPoint == rhs.m_focalPoint &&
m_stops == rhs.m_stops;
}
KoAbstractGradient* KoStopGradient::clone() const
{
return new KoStopGradient(*this);
......
......@@ -25,19 +25,22 @@
#include <resources/KoAbstractGradient.h>
#include <resources/KoResource.h>
#include <kritapigment_export.h>
#include <boost/operators.hpp>
typedef QPair<qreal, KoColor> KoGradientStop;
/**
* Resource for colorstop based gradients like Karbon gradients and SVG gradients
*/
class KRITAPIGMENT_EXPORT KoStopGradient : public KoAbstractGradient
class KRITAPIGMENT_EXPORT KoStopGradient : public KoAbstractGradient, public boost::equality_comparable<KoStopGradient>
{
public:
explicit KoStopGradient(const QString &filename = QString());
~KoStopGradient() override;
bool operator==(const KoStopGradient &rhs) const;
KoAbstractGradient* clone() const override;
bool load() override;
......
......@@ -740,6 +740,32 @@ void KoFillConfigWidget::shapeChanged()
}
}
bool KoFillConfigWidget::checkNewFillModeIsSame(const KoShapeFillWrapper &w) const
{
bool retval = false;
switch (w.type()) {
case KoFlake::None:
retval = d->selectedFillIndex == None;
break;
case KoFlake::Solid:
retval = d->selectedFillIndex == Solid && w.color() == d->colorAction->currentColor();
break;
case KoFlake::Gradient: {
QScopedPointer<KoStopGradient> newGradient(KoStopGradient::fromQGradient(w.gradient()));
retval = d->selectedFillIndex == Gradient && *newGradient == *d->activeGradient;
break;
}
case KoFlake::Pattern:
// TODO: not implemented
retval = d->selectedFillIndex == Pattern && false;
break;
}
return retval;
}
void KoFillConfigWidget::updateWidget(KoShape *shape)
{
KIS_SAFE_ASSERT_RECOVER_RETURN(shape);
......@@ -747,6 +773,8 @@ void KoFillConfigWidget::updateWidget(KoShape *shape)
StyleButton newActiveButton = None;
KoShapeFillWrapper wrapper(shape, d->fillVariant);
if (checkNewFillModeIsSame(wrapper)) return;
switch (wrapper.type()) {
case KoFlake::None:
break;
......
......@@ -28,6 +28,7 @@
#include <KoFlake.h>
#include <KoFlakeTypes.h>
class KoShapeFillWrapper;
class KoCanvasBase;
class KoShapeBackground;
class KoShape;
......@@ -113,6 +114,8 @@ private:
void updateWidgetComponentVisbility();
bool checkNewFillModeIsSame(const KoShapeFillWrapper &w) const;
class Private;
Private * const d;
};
......
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