summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview
diff options
context:
space:
mode:
authorZhang Hao <zhanghao@uniontech.com>2020-06-30 10:08:36 +0800
committerZhang Hao <zhanghao@uniontech.com>2020-09-18 09:17:37 +0800
commit3983afd48f27cdbb006720957ff34cf58f126ca5 (patch)
treeae6566fac7cee10e4035d91907c0df25398e3a2f /src/widgets/graphicsview
parent18cda2f669acd303f540cda12cc9bb655a7f1282 (diff)
QGraphicsView:QGraphicstextitem show error after lose focus
The reason for this bug is that after the TextItem loses focus, the focusItem in QGraphicsScene is already empty. When QGraphicsScene responds to the inputMethodEvent event again, since focusItem is already empty,focusItem will no longer deliver events. Fixes:QTBUG-85088 Pick-to:5.15 Change-Id: I329054333c2adec133d35318761612aca3afcf0d Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index f272720150..8c93515d14 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -4143,8 +4143,12 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event)
{
Q_D(QGraphicsScene);
- if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
+ if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
d->sendEvent(d->focusItem, event);
+ return;
+ }
+ if (d->lastFocusItem && d->lastFocusItem != d->focusItem && (d->lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
+ d->sendEvent(d->lastFocusItem, event);
}
/*!