diff --git a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
index 56d0db99740c992aa22fe51c10fae900021ac481..605480ad22a881d0cb974f1d37533f47e427d79d 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/formeditoritem.cpp
@@ -198,7 +198,8 @@ FormEditorItem* FormEditorItem::fromQGraphicsItem(QGraphicsItem *graphicsItem)
 
 void FormEditorItem::paintBoundingRect(QPainter *painter) const
 {
-    if (QGraphicsItem::parentItem() == scene()->formLayerItem() && qFuzzyIsNull(m_borderWidth))
+    if (!boundingRect().isValid()
+        || (QGraphicsItem::parentItem() == scene()->formLayerItem() && qFuzzyIsNull(m_borderWidth)))
           return;
 
     QPen pen;
@@ -234,9 +235,7 @@ void FormEditorItem::paintBoundingRect(QPainter *painter) const
     painter->setPen(pen);
 //    int offset =  m_borderWidth / 2;
 
-    const QRectF br = boundingRect();
-    if (br.isValid())
-        painter->drawRect(br.adjusted(0., 0., -1., -1.));
+    painter->drawRect(boundingRect().adjusted(0., 0., -1., -1.));
 }
 
 void FormEditorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)