Fix potential issues with ACCESS_VIOLATION_READ.

This commit is contained in:
Roman Telezhynskyi 2024-07-09 14:56:26 +03:00
parent 42ced535cb
commit f1d0c89f83

View file

@ -4668,15 +4668,19 @@ template <typename T> auto VPattern::ToolBoundingRect(const QRectF &rec, quint32
QRectF recTool = rec; QRectF recTool = rec;
if (tools.contains(id)) if (tools.contains(id))
{ {
const T *vTool = qobject_cast<T *>(tools.value(id)); if (const T *vTool = qobject_cast<T *>(tools.value(id)); vTool != nullptr)
SCASSERT(vTool != nullptr) {
QRectF childrenRect = vTool->childrenBoundingRect();
// map to scene coordinate.
childrenRect.translate(vTool->scenePos());
QRectF childrenRect = vTool->childrenBoundingRect(); recTool = recTool.united(vTool->sceneBoundingRect());
// map to scene coordinate. recTool = recTool.united(childrenRect);
childrenRect.translate(vTool->scenePos()); }
else
recTool = recTool.united(vTool->sceneBoundingRect()); {
recTool = recTool.united(childrenRect); qDebug() << "qobject_cast failed for tool with id=" << id;
}
} }
else else
{ {