diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2011-05-02 10:39:45 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2011-05-02 10:55:34 (GMT) |
commit | 6db0153cd7e35e4a919a76ae2aadbf2d2510bfb7 (patch) | |
tree | c908f0b9f167aa4aa2cdacb3ffd962dd261999ef /tests/auto | |
parent | 1308909157ec62d1f55135ce40090d7383e0db17 (diff) | |
download | Qt-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')
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 25 |
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: |