diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index 539105f28..1a80adbcb 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -281,18 +281,23 @@ FrameSvgItem::~FrameSvgItem() class CheckMarginsChange { public: - CheckMarginsChange(FrameSvgItemMargins *margins) - : m_oldMargins(margins ? margins->margins() : QVector()), m_margins(margins) + CheckMarginsChange(QVector& oldMargins, FrameSvgItemMargins *marginsObject) + : m_oldMargins(oldMargins), m_marginsObject(marginsObject) {} - ~CheckMarginsChange() { - if (m_margins && m_margins->margins() != m_oldMargins) { - m_margins->update(); + ~CheckMarginsChange() + { + const QVector oldMarginsBefore = m_oldMargins; + m_oldMargins = m_marginsObject ? m_marginsObject->margins() : QVector(); + + if (oldMarginsBefore != m_oldMargins) { + m_marginsObject->update(); } } - const QVector m_oldMargins; - FrameSvgItemMargins *const m_margins; +private: + QVector& m_oldMargins; + FrameSvgItemMargins *const m_marginsObject; }; void FrameSvgItem::setImagePath(const QString &path) @@ -301,8 +306,8 @@ void FrameSvgItem::setImagePath(const QString &path) return; } - CheckMarginsChange checkMargins(m_margins); - CheckMarginsChange checkFixedMargins(m_fixedMargins); + CheckMarginsChange checkMargins(m_oldMargins, m_margins); + CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); updateDevicePixelRatio(); m_frameSvg->setImagePath(path); @@ -345,8 +350,8 @@ void FrameSvgItem::setPrefix(const QVariant &prefixes) return; } - CheckMarginsChange checkMargins(m_margins); - CheckMarginsChange checkFixedMargins(m_fixedMargins); + CheckMarginsChange checkMargins(m_oldMargins, m_margins); + CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); m_prefixes = prefixList; applyPrefixes(); @@ -432,7 +437,7 @@ void FrameSvgItem::setEnabledBorders(const Plasma::FrameSvg::EnabledBorders bord return; } - CheckMarginsChange checkMargins(m_margins); + CheckMarginsChange checkMargins(m_oldMargins, m_margins); m_frameSvg->setEnabledBorders(borders); emit enabledBordersChanged(); @@ -466,8 +471,8 @@ void FrameSvgItem::doUpdate() return; } - CheckMarginsChange checkMargins(m_margins); - CheckMarginsChange checkFixedMargins(m_fixedMargins); + CheckMarginsChange checkMargins(m_oldMargins, m_margins); + CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); //if the theme changed, the available prefix may have changed as well applyPrefixes(); @@ -601,8 +606,8 @@ void FrameSvgItem::classBegin() void FrameSvgItem::componentComplete() { - CheckMarginsChange checkMargins(m_margins); - CheckMarginsChange checkFixedMargins(m_fixedMargins); + CheckMarginsChange checkMargins(m_oldMargins, m_margins); + CheckMarginsChange checkFixedMargins(m_oldFixedMargins, m_fixedMargins); QQuickItem::componentComplete(); m_frameSvg->resizeFrame(QSize(width(), height())); diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h index a82330fdc..b92cba35c 100644 --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -255,6 +255,9 @@ private: Plasma::FrameSvg *m_frameSvg; FrameSvgItemMargins *m_margins; FrameSvgItemMargins *m_fixedMargins; + // logged margins to check for changes + QVector m_oldMargins; + QVector m_oldFixedMargins; QStringList m_prefixes; bool m_textureChanged; bool m_sizeChanged;