Fixed issue #851. Mouse click on a highlighted object crashes Valentina.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-05-24 09:56:19 +03:00
parent c6e38932dc
commit bb95c3162b

View File

@ -536,31 +536,24 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *event)
{ {
QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag); QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag);
} }
if (showToolOptions) if (showToolOptions)
{ {
QList<QGraphicsItem *> list = items(event->pos()); bool success = false;
if (list.size() == 0) const QList<QGraphicsItem *> list = items(event->pos());
{
emit itemClicked(nullptr);
break;
}
const QList<QGraphicsItem *> sceneItems = this->scene()->items();
for (auto item : list) for (auto item : list)
{ {
if (sceneItems.contains(item)) if (item && item->type() > QGraphicsItem::UserType && item->type() <= VSimpleCurve::Type)
{ {
if (item->type() > QGraphicsItem::UserType && item->type() <= VSimpleCurve::Type) emit itemClicked(item);
{ success = true;
emit itemClicked(item);
break;
}
else
{
emit itemClicked(nullptr);
}
} }
} }
if (not success)
{
emit itemClicked(nullptr);
}
} }
break; break;
} }