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,9 +4668,8 @@ template <typename T> auto VPattern::ToolBoundingRect(const QRectF &rec, quint32
QRectF recTool = rec;
if (tools.contains(id))
{
const T *vTool = qobject_cast<T *>(tools.value(id));
SCASSERT(vTool != nullptr)
if (const T *vTool = qobject_cast<T *>(tools.value(id)); vTool != nullptr)
{
QRectF childrenRect = vTool->childrenBoundingRect();
// map to scene coordinate.
childrenRect.translate(vTool->scenePos());
@ -4679,6 +4678,11 @@ template <typename T> auto VPattern::ToolBoundingRect(const QRectF &rec, quint32
recTool = recTool.united(childrenRect);
}
else
{
qDebug() << "qobject_cast failed for tool with id=" << id;
}
}
else
{
qDebug() << "Can't find tool with id=" << id;
}