From f008f55c7705b5535c4ee7ffc2318eb6c6f194be Mon Sep 17 00:00:00 2001 From: afaina Date: Mon, 22 Aug 2022 00:58:14 +0200 Subject: [PATCH 1/2] fixes problems when displaying info (tooltip)of hybrid connectors. Hybrid connectors must not be shown. Fixes #3578 --- src/sketch/fgraphicsscene.cpp | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/sketch/fgraphicsscene.cpp b/src/sketch/fgraphicsscene.cpp index cc8e5bd1a..0178dc67b 100644 --- a/src/sketch/fgraphicsscene.cpp +++ b/src/sketch/fgraphicsscene.cpp @@ -35,23 +35,40 @@ FGraphicsScene::FGraphicsScene( QObject * parent) : QGraphicsScene(parent) void FGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) { // TODO: how do we get a QTransform? - QGraphicsItem * item = this->itemAt(helpEvent->scenePos(), QTransform()); - if (item == NULL) return; + QList itemList = this->items(helpEvent->scenePos(), Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform()); + bool found = false; QString text; QPoint point; - ItemBase * itemBase = dynamic_cast(item); - if (itemBase == NULL) { - ConnectorItem * connectorItem = dynamic_cast(item); - if (connectorItem) { - connectorItem->updateTooltip(); + QGraphicsItem * item; + + //Find connectors first + for (int i = 0; i < itemList.size(); i++) { + item = itemList.at(i); + ItemBase * itemBase = dynamic_cast(item); + if (itemBase == NULL) { + ConnectorItem * connectorItem = dynamic_cast(item); + if (connectorItem && !connectorItem->isHybrid()) { + connectorItem->updateTooltip(); + found = true; + break; + } } - } - else { - itemBase->updateTooltip(); + + //If there are not connectors, find parts + if (!found){ + for (int i = 0; i < itemList.size(); i++) { + item = itemList.at(i); + ItemBase * itemBase = dynamic_cast(item); + if (itemBase) { + itemBase->updateTooltip(); + break; + } + } } + if (!item->toolTip().isEmpty()) { text = item->toolTip(); point = helpEvent->screenPos(); From 7770a51841d66e9890b18460fea387b79ff1dbc1 Mon Sep 17 00:00:00 2001 From: afaina Date: Mon, 22 Aug 2022 10:07:52 +0200 Subject: [PATCH 2/2] avoid crashes caused by previous commit --- src/sketch/fgraphicsscene.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/sketch/fgraphicsscene.cpp b/src/sketch/fgraphicsscene.cpp index 0178dc67b..206e67c19 100644 --- a/src/sketch/fgraphicsscene.cpp +++ b/src/sketch/fgraphicsscene.cpp @@ -40,7 +40,7 @@ void FGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) bool found = false; QString text; QPoint point; - QGraphicsItem * item; + QGraphicsItem * item = nullptr; //Find connectors first for (int i = 0; i < itemList.size(); i++) { @@ -68,6 +68,7 @@ void FGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) } } + if(!item) return; if (!item->toolTip().isEmpty()) { text = item->toolTip();