path: root/src/widgets
diff options
authorAndreas Aardal Hanssen <>2012-12-17 10:10:35 +0100
committerThe Qt Project <>2012-12-17 11:57:02 +0100
commited15e4eb07104dd780fe8d72b2792916ce4db098 (patch)
tree10f5fa7b7a4cf4fe6e43e3840dc631f28ac71e7d /src/widgets
parent8c814db74718f18e88697feb97867b0d502e7f1d (diff)
Fix focusproxy-relayed crash in QGraphicsItem destructor.
Makes tst_qgraphicsitem::tst_focusProxyDeletion not crash. valgrind reported the error when running tst_qgraphicsitem. The crash was very real; when deleting an item that has another item as a focus proxy, the proxy still had a reference to the deleted item's focusProxy pointer. I'm not a huge fan of whitebox testing but thought this crash justifies a modification of the test to make it fail, instead of just passing silently with a warning only given by valgrind and friends. FTR the reason the test doesn't crash hard is that the memory is freed but not reused within the scope of the test. So the access to the pointer d_ptr->focusProxy succeeds, it just accesses memory that might as well have been reclaimed. But this is quite undefined... Task-number: QTBUG-28321 Change-Id: I2624631f5e5c2a8aa8bd4efe1fc128eba6c61f56 Reviewed-by: Jan Arve Sæther <>
Diffstat (limited to 'src/widgets')
1 files changed, 1 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index f9b8cb83da..3ba9b89e34 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1436,6 +1436,7 @@ QGraphicsItem::~QGraphicsItem()
+ setFocusProxy(0);
// Update focus scope item ptr.
QGraphicsItem *p = d_ptr->parent;