forked from qt-creator/qt-creator
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 <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -335,7 +335,19 @@ QRectF QuickItemNodeInstance::boundingRect() const
|
|||||||
if (quickItem()->clip()) {
|
if (quickItem()->clip()) {
|
||||||
return quickItem()->boundingRect();
|
return quickItem()->boundingRect();
|
||||||
} else {
|
} 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)
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
QSize size = renderBoundingRect.size().toSize();
|
QSize size = renderBoundingRect.size().toSize();
|
||||||
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble();
|
||||||
if (size.width() * size.height() > 4000 * 4000)
|
|
||||||
size = QSize(0,0);
|
|
||||||
size *= devicePixelRatio;
|
size *= devicePixelRatio;
|
||||||
|
|
||||||
if (s_unifiedRenderPath) {
|
if (s_unifiedRenderPath) {
|
||||||
|
Reference in New Issue
Block a user