Skip to content

Commit ee60e9c

Browse files
author
Damian Jansen
committed
Fix focusScopeItemChange setting crash
Delay focusScopeItemChange to after reparenting, to prevent an invalid focusScopeItem pointer crash. Task-number: QTBUG-21640 Reviewed-by: Martin Jones
1 parent 7a0cdd8 commit ee60e9c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/gui/graphicsview/qgraphicsitem.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,6 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
11571157
if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
11581158
parentFocusScopeItem = fsi;
11591159
p->d_ptr->focusScopeItem = 0;
1160-
fsi->d_ptr->focusScopeItemChange(false);
11611160
}
11621161
break;
11631162
}
@@ -1259,6 +1258,10 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const Q
12591258
if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData)))
12601259
transformChanged();
12611260

1261+
// Reparenting is finished, now safe to notify the previous focusScopeItem about changes
1262+
if (parentFocusScopeItem)
1263+
parentFocusScopeItem->d_ptr->focusScopeItemChange(false);
1264+
12621265
// Restore the sub focus chain.
12631266
if (subFocusItem) {
12641267
subFocusItem->d_ptr->setSubFocus(newParent);

0 commit comments

Comments
 (0)