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,32 +536,25 @@ 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); emit itemClicked(item);
break; success = true;
} }
else }
if (not success)
{ {
emit itemClicked(nullptr); emit itemClicked(nullptr);
} }
} }
}
}
break; break;
} }
case Qt::MiddleButton: case Qt::MiddleButton: