summaryrefslogtreecommitdiffstats
path: root/tests/auto/qwidget/tst_qwidget.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-10-15 18:45:13 +0200
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-10-15 22:03:51 +0200
commit8ef83e60df0291ba2a36cc744e1f0c11f465f1e2 (patch)
tree15c5e1d40451e5a3a6cb81bc972a4a88fdfeff46 /tests/auto/qwidget/tst_qwidget.cpp
parentbdc951eb87e0b1aa752d3ec750cfd837714bd8b7 (diff)
Fixed a rare crash in qt_x11_enforce_cursor
A QPointer was set to point to a QWidget by one of its children, during its deletion. This happens during the child deletion, and after the call to QObject::clearGuards(), which means that the QPointer becomes a dangling one. The fix ensures that qt_x11_enforce_cursor will not be called with a being-deleted QWidget. The included auto-test doesn't test anything, except that it doesn't crash. Reviewed-by: Olivier
Diffstat (limited to 'tests/auto/qwidget/tst_qwidget.cpp')
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index daeee3dfe9..4cb9f72a5d 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -69,6 +69,9 @@
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
+#include <QtGui/QGraphicsView>
+#include <QtGui/QGraphicsProxyWidget>
+
#include "../../shared/util.h"
@@ -285,6 +288,7 @@ private slots:
#ifdef Q_WS_X11
void minAndMaxSizeWithX11BypassWindowManagerHint();
void showHideShow();
+ void clean_qt_x11_enforce_cursor();
#endif
void compatibilityChildInsertedEvents();
@@ -6048,6 +6052,35 @@ void tst_QWidget::showHideShow()
QVERIFY(w.gotExpectedMapNotify);
}
+
+void tst_QWidget::clean_qt_x11_enforce_cursor()
+{
+ {
+ QWidget window;
+ QWidget *w = new QWidget(&window);
+ QWidget *child = new QWidget(w);
+ child->setAttribute(Qt::WA_SetCursor, true);
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QTest::qWaitForWindowShown(&window);
+ QTest::qWait(100);
+ QCursor::setPos(window.geometry().center());
+ QTest::qWait(100);
+
+ child->setFocus();
+ QApplication::processEvents();
+ QTest::qWait(100);
+
+ delete w;
+ }
+
+ QGraphicsScene scene;
+ QLineEdit *edit = new QLineEdit;
+ scene.addWidget(edit);
+
+ // If the test didn't crash, then it passed.
+}
#endif
class EventRecorder : public QObject