From ed465a81f5d522a7e1a8ba0c07972d3e3f2f3e97 Mon Sep 17 00:00:00 2001 From: Knud Dollereder Date: Mon, 27 Sep 2021 10:00:59 +0200 Subject: [PATCH] Do not reset the render-image size to (0,0) when reaching the size limit The size of the image to be rendered for the FormEditor is computed from the bounding box enclosing the items within the scene. There is a size limit, when reached the size was reset to (0,0) leading to an empty FormEditor image. This is now fixed by returning the bounding box of the root item in case this limit is reached. Change-Id: I58366610da2e90c34aea6117e225765ff4b3288b Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../instances/quickitemnodeinstance.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp index 7557e87ccee..2046a2039e1 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp @@ -335,7 +335,19 @@ QRectF QuickItemNodeInstance::boundingRect() const if (quickItem()->clip()) { return quickItem()->boundingRect(); } else { - return boundingRectWithStepChilds(quickItem()); + QSize maximumSize(4000, 4000); + auto isValidSize = [maximumSize] (const QRectF& rect) { + QSize size = rect.size().toSize(); + return size.width() * size.height() <= maximumSize.width() * maximumSize.height(); + }; + + QRectF rect = boundingRectWithStepChilds(quickItem()); + if (isValidSize(rect)) + return rect; + else if (rect = quickItem()->boundingRect(); isValidSize(rect)) + return rect; + else + return QRectF(QPointF(0.0, 0.0), maximumSize); } } @@ -462,8 +474,6 @@ QImage QuickItemNodeInstance::renderImage() const #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSize size = renderBoundingRect.size().toSize(); static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble(); - if (size.width() * size.height() > 4000 * 4000) - size = QSize(0,0); size *= devicePixelRatio; if (s_unifiedRenderPath) {