summaryrefslogtreecommitdiffstats
path: root/tests/auto/qwidget
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2011-05-02 10:39:45 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2011-05-02 10:55:34 (GMT)
commit6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7 (patch)
treec908f0b9f167aa4aa2cdacb3ffd962dd261999ef /tests/auto/qwidget
parent1308909157ec62d1f55135ce40090d7383e0db17 (diff)
downloadQt-6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7.zip
Qt-6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7.tar.gz
Qt-6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7.tar.bz2
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
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 bb8b8b4..a851d03 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();
@@ -8522,6 +8523,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: