From 6bff4ef469e27ea6fceb1b21a03db366145040de Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 13 Feb 2014 12:45:21 +0100 Subject: [PATCH] Avoid frame resizing till componentCompleted --- src/declarativeimports/core/framesvgitem.cpp | 24 ++++++++++++++++---- src/declarativeimports/core/framesvgitem.h | 3 +++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/declarativeimports/core/framesvgitem.cpp b/src/declarativeimports/core/framesvgitem.cpp index b9f14eebb..1826d8854 100644 --- a/src/declarativeimports/core/framesvgitem.cpp +++ b/src/declarativeimports/core/framesvgitem.cpp @@ -94,8 +94,10 @@ void FrameSvgItem::setImagePath(const QString &path) emit imagePathChanged(); m_margins->update(); - m_frameSvg->resizeFrame(QSizeF(width(), height())); - update(); + if (isComponentComplete()) { + m_frameSvg->resizeFrame(QSizeF(width(), height())); + update(); + } } QString FrameSvgItem::imagePath() const @@ -123,8 +125,11 @@ void FrameSvgItem::setPrefix(const QString &prefix) emit prefixChanged(); m_margins->update(); - m_frameSvg->resizeFrame(QSizeF(width(), height())); - update(); + + if (isComponentComplete()) { + m_frameSvg->resizeFrame(QSizeF(width(), height())); + update(); + } } QString FrameSvgItem::prefix() const @@ -160,7 +165,9 @@ void FrameSvgItem::paint(QPainter *painter) void FrameSvgItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { - m_frameSvg->resizeFrame(newGeometry.size()); + if (isComponentComplete()) { + m_frameSvg->resizeFrame(newGeometry.size()); + } QQuickItem::geometryChanged(newGeometry, oldGeometry); } @@ -214,6 +221,13 @@ Plasma::FrameSvg *FrameSvgItem::frameSvg() const return m_frameSvg; } +void FrameSvgItem::componentComplete() +{ + QQuickItem::componentComplete(); + m_frameSvg->resizeFrame(QSize(width(), height())); +} + + } // Plasma namespace #include "framesvgitem.moc" diff --git a/src/declarativeimports/core/framesvgitem.h b/src/declarativeimports/core/framesvgitem.h index 458570cc0..e348c4c78 100644 --- a/src/declarativeimports/core/framesvgitem.h +++ b/src/declarativeimports/core/framesvgitem.h @@ -143,6 +143,9 @@ public: */ Plasma::FrameSvg *frameSvg() const; +protected: + virtual void componentComplete(); + Q_SIGNALS: void imagePathChanged(); void prefixChanged();