summaryrefslogtreecommitdiffstats
path: root/tests/auto/qwidget
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2011-05-02 12:39:45 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-11 16:38:49 +0200
commit1e41e3076aab37f151ffc09e6cd5768289e0d3e9 (patch)
tree1c5870ebf6dd09fb1f3ebe874ea5dc194a2a5a37 /tests/auto/qwidget
parent7ee981a834c8b0b8eddf600965a446c5bb124a91 (diff)
Fixes crash in QWidget::effectiveWinId.
Widgets are left in a transitional (and incosistent) state while being re-parented, which caused QWidget::effectiveWinId() to crash in certain circumstances. See patch for more details. Auto test included. Reviewed-by: ogoffart (cherry picked from commit 6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7)
Diffstat (limited to 'tests/auto/qwidget')
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index e266efb794..f282b5d7d3 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -345,6 +345,7 @@ private slots:
void immediateRepaintAfterInvalidateBuffer();
#endif
void effectiveWinId();
+ void effectiveWinId2();
void customDpi();
void customDpiProperty();
@@ -8495,6 +8496,30 @@ void tst_QWidget::effectiveWinId()
QVERIFY(child.effectiveWinId());
}
+void tst_QWidget::effectiveWinId2()
+{
+ QWidget parent;
+
+ class MyWidget : public QWidget {
+ bool event(QEvent *e)
+ {
+ if (e->type() == QEvent::WinIdChange) {
+ // Shouldn't crash.
+ effectiveWinId();
+ }
+
+ return QWidget::event(e);
+ }
+ };
+
+ MyWidget child;
+ child.setParent(&parent);
+ parent.show();
+
+ child.setParent(0);
+ child.setParent(&parent);
+}
+
class CustomWidget : public QWidget
{
public: